Beispiel #1
0
 protected function checkAuth()
 {
     if (!Auth::check()) {
         throw new \App\Exceptions\ExceptionApiAuthRequire($this->_request_params, $this->_typeName, $this->_methodName);
     }
     return true;
 }
Beispiel #2
0
 public function delete()
 {
     $this->_methodName = 'delete';
     if (!Auth::check() || !Auth::checkAdmin()) {
         throw new \App\Exceptions\ExceptionApiMethodbad($this->_typeName, $this->_methodName, $this->_request_params);
     }
     $this->resolveParams();
     $arNeed = ['taskId' => 'required|numeric'];
     $this->checkAttr($arNeed);
     $task = \App\Task::find($this->_request_params['taskId']);
     if (!is_null($task)) {
         $task_users = \App\UserTask::where(['id_task' => $task->id])->get();
         foreach ($task_users as $value) {
             $infoTask = \App\InfoTask::where('id_taskUser', $task_user->id)->first();
             if (!is_null($infoTask)) {
                 $infoTask->delete();
             }
             $value->delete();
         }
         $task->delete();
         return $this;
     } else {
         throw new \App\Exceptions\ExceptionApiUserNotFound($this->_request_params, $this->_typeName, $this->_methodName);
     }
 }
Beispiel #3
0
 public function delete()
 {
     $this->_methodName = 'delete';
     if (!Auth::check() || !Auth::checkAdmin()) {
         throw new \App\Exceptions\ExceptionApiMethodbad($this->_typeName, $this->_methodName, $this->_request_params);
     }
     $this->resolveParams();
     $arNeed = ['userId' => 'required|numeric'];
     $this->checkAttr($arNeed);
     $reg_user = \App\Users::find($this->_request_params['userId']);
     if (!is_null($reg_user)) {
         $reg_user->delete();
         return $this;
     } else {
         throw new \App\Exceptions\ExceptionApiUserNotFound($this->_request_params, $this->_typeName, $this->_methodName);
     }
 }
Beispiel #4
0
 /**
  * @param $results
  * @return mixed
  */
 public function formatProductDataForAjax($results)
 {
     foreach ($results as &$item) {
         $item->urlProductDetail = urlProductDetail($item);
         $item->sell_price_show = formatMoney($item->sell_price);
         $item->discount_show = formatMoney($item->discount);
         $item->price_after_discount_show = formatMoney($item->sell_price - $item->discount);
         $item->style = $item->style->toArray();
         $item->is_loggin = \Auth::check() ? 1 : 0;
         if (count($item->properties)) {
             $item->properties_js = $item->properties;
         } else {
             $item->properties_js = 0;
         }
     }
     return $results->toArray();
 }