Ejemplo n.º 1
0
 /**
  * Updates a work order report.
  *
  * @param ReportRequest $request
  * @param int|string $reportId
  *
  * @return bool|\Illuminate\Database\Eloquent\Model|null
  */
 public function update(ReportRequest $request, $reportId)
 {
     $report = $this->find($reportId);
     if ($report) {
         $report->description = $request->clean($request->input('description', $report->description));
         if ($report->save()) {
             return $report;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Completes the work order by saving the completed at timestamp to now.
  *
  * @param ReportRequest $request
  *
  * @return $this|bool
  */
 public function complete(ReportRequest $request)
 {
     if (!$this->started_at) {
         $this->started_at = Carbon::now();
     }
     $this->completed_at = Carbon::now();
     if ($request->has('status')) {
         $status = $this->status()->getRelated()->find($request->input('status'));
         if ($status) {
             $this->status_id = $status->id;
         }
     }
     if ($this->save()) {
         return $this;
     }
     return false;
 }