where('date',$date)->select('left','num')->first(); if($info){ return $info->left; } return -1; } public static function create(array $data){ if( WelfarePrize::where('channel_user_id',$data['channel_user_id'])->where('date',$data['date'])->count()){ return null; } return WelfarePrize::create($data); } public static function getByToday(int $channel_user_id){ $info = WelfarePrize::where('channel_user_id',$channel_user_id)->where('date',date('Y-m-d'))->select('id','left','num')->first(); return $info; } public static function decrementLeft($id){ WelfarePrize::where('id', $id)->decrement('left'); } }