Example #1
0
 public function getListActive()
 {
     $this->_methodName = 'getListActive';
     $this->resolveParams();
     $this->checkAuth();
     if (!$this->checkUserUnable() || Auth::checkAdmin()) {
         throw new \App\Exceptions\ExceptionApiNotFulInfo($this->_request_params, $this->_typeName, $this->_methodName);
     }
     $date = Carbon::now();
     $limit = 30;
     if (isset($this->_request_params['beforeDate'])) {
         $arNeed = ['beforeDate' => 'required|date|date_format:"Y-m-d H:i:s"'];
         $this->checkAttr($arNeed);
         $date = $this->_request_params['beforeDate'];
     }
     if (isset($this->_request_params['limit'])) {
         $arNeed = ['limit' => 'required|integer'];
         $this->checkAttr($arNeed);
         $limit = $this->_request_params['limit'];
     }
     $tasks = \App\UserTask::select('id_task')->where('id_user', Auth::id())->whereStatus('active')->get();
     $this->_arData['data']['nowDate'] = Carbon::now()->toDateTimeString();
     if (is_null($tasks)) {
         $this->_arData['data'] = [];
     } else {
         foreach ($tasks as $task_user) {
             $task = \App\Task::whereId($task_user->id_task)->first();
             $this->_arData['data']['list'][] = ['userTaskId' => (int) $task_user->id, 'taskId' => (int) $task_user->id_task, 'name' => $task->name, 'timer' => $task->timer, 'score' => (int) $task->point];
         }
     }
     return $this;
 }