/**
  * Creates a user work request.
  *
  * @param WorkRequest $request
  *
  * @return bool|\Stevebauman\Maintenance\Models\WorkRequest
  */
 public function create(WorkRequest $request)
 {
     $attributes = ['subject' => $request->input('subject'), 'description' => $request->clean($request->input('description')), 'best_time' => $request->input('best_time')];
     $workRequest = $this->model()->create($attributes);
     if ($workRequest) {
         $autoGenerate = $this->config->setPrefix('maintenance')->get('rules.work-orders.auto_generate_from_request', true);
         if ($autoGenerate) {
             $this->workOrder->createFromWorkRequest($workRequest);
         }
         return $workRequest;
     }
     return false;
 }
Пример #2
0
 /**
  * Creates a new work request.
  *
  * @param Request $request
  *
  * @return bool|WorkRequest
  */
 public function create(Request $request)
 {
     $workRequest = $this->model();
     $workRequest->user_id = $this->sentry->getCurrentUserId();
     $workRequest->subject = $request->input('subject');
     $workRequest->best_time = $request->input('best_time');
     $workRequest->description = $request->clean($request->input('description'));
     if ($workRequest->save()) {
         $autoGenerate = $this->config->setPrefix('maintenance')->get('rules.work-orders.auto_generate_from_request', true);
         if ($autoGenerate) {
             $this->workOrder->createFromWorkRequest($workRequest);
         }
         return $workRequest;
     }
     return false;
 }