1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Repositories;
- use App\Models\TaskLog;
- use Prettus\Repository\Eloquent\BaseRepository;
- use Prettus\Repository\Criteria\RequestCriteria;
- /**
- * Class MemberRepositoryEloquent.
- *
- * @package namespace App\Repositories;
- */
- class TaskLogRepository extends BaseRepository
- {
- /**
- * Specify Model class name
- *
- * @return string
- */
- public function model()
- {
- return TaskLog::class;
- }
- /**
- * Boot up the repository, pushing criteria
- */
- public function boot()
- {
- $this->pushCriteria(app(RequestCriteria::class));
- }
- public function getTaskLog($uid, $task, $utype)
- {
- return $this->model->where(['uid'=>$uid,'task_id'=>$task->id,'utype'=>$utype])->first();
- }
- public function getTaskLogCount($uid, $task_id, $utype)
- {
- return $this->model->where(['uid'=>$uid,'task_id'=>$task_id,'utype'=>$utype])->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('created_at', '<=', date('Y-m-d 23:59:59'))->count();
- }
- public function addNew($data)
- {
- return $this->model->create($data);
- }
- /**
- * 获取今日的积分。
- */
- public function getTodayPoints($uid, $utype)
- {
- return $this->model->where(['uid'=>$uid,'utype'=>$utype])->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('created_at', '<=', date('Y-m-d 23:59:59'))->sum('points');
- }
- /**
- * 获取单次的积分。
- */
- public function getSinglePoints($uid, $utype)
- {
- return $this->model->where(['uid'=>$uid,'utype'=>$utype,'once'=>1])->sum('points');
- }
- /**
- * 获取当天日常的积分。
- */
- public function getDayPoints($uid, $utype)
- {
- return $this->model->where(['uid'=>$uid,'utype'=>$utype,'once'=>0])->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('created_at', '<=', date('Y-m-d 23:59:59'))->sum('points');
- }
- public function getTlog($uid, $task_id, $utype)
- {
- return $this->model->where(['uid'=>$uid,'task_id'=>$task_id,'utype'=>$utype])->first();
- }
- }
|