1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace App\Repositories;
- use App\Models\TaskLog;
- use Prettus\Repository\Eloquent\BaseRepository;
- use Prettus\Repository\Criteria\RequestCriteria;
- class TaskLogRepository extends BaseRepository
- {
-
- public function model()
- {
- return TaskLog::class;
- }
-
- 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();
- }
- }
|