/**
  * Returns a new grid instance of all of the current users work requests.
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid()
 {
     $columns = ['id', 'subject', 'description', 'best_time', 'created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (WorkRequest $workRequest) {
         $attributes = ['id' => $workRequest->id, 'subject' => $workRequest->subject, 'description' => $workRequest->getLimitedDescriptionAttribute(), 'best_time' => $workRequest->best_time, 'created_at' => $workRequest->created_at, 'view_url' => route('maintenance.client.work-requests.show', [$workRequest->id])];
         if ($workRequest->workOrder && $workRequest->workOrder->status) {
             $attributes['status'] = $workRequest->workOrder->status->label;
         } else {
             $attributes['status'] = '<em>None</em>';
         }
         return $attributes;
     };
     return $this->workRequest->grid($columns, $settings, $transformer);
 }
示例#2
0
 /**
  * Deletes a users work request.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     $workRequest = $this->workRequest->model()->findOrFail($id);
     if ($workRequest->delete()) {
         $message = 'Successfully deleted work request.';
         return redirect()->route('maintenance.client.work-requests.index')->withSuccess($message);
     } else {
         $message = 'There was an issue deleting this work request. Please try again.';
         return redirect()->route('maintenance.client.work-requests.show', [$id])->withErrors($message);
     }
 }