12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2019/6/6
- * Time: 18:05
- */
- namespace App\Traits;
- use App\Models\Post;
- use Illuminate\Support\Facades\Redis;
- trait PostTrait
- {
- // public function __construct(Post $post) {
- // $this->post = $post;
- // }
- //预计可获得U米数
- public function availableBean()
- {
- $bean = Redis::get('yesterday_post_create_bean');
- $count = Redis::get('yesterday_post_count');
- $num = 1000;
- if($bean && $count){
- $num = $bean / $count;
- }
- $h = date('h');
- $H = date('H');
- $t = $h * 60 / 720 + 2;
- if(in_array(intval($H), [9,10,11,12,17.18,19,20,21])){
- $t += 0.5;
- }
- return intval($num * $t);
- }
- //详情
- public function detail($id)
- {
- return Post::join('post_data', 'post_data.post_id', '=', 'post.id')
- ->select('post.*')
- ->find($id);
- }
- }
|