/**
  * Runs the seeding operations.
  */
 public function run()
 {
     $priorities = $this->getSeedData();
     foreach ($priorities as $priority) {
         $this->priority->model()->create($priority);
     }
 }
 /**
  * @param $view
  *
  * @return mixed
  */
 public function compose(View $view)
 {
     $priorities = $this->priority->all()->lists('name', 'id')->toArray();
     /*
      * Default selected None value
      */
     $priorities[null] = 'Select a Priority';
     return $view->with('priorities', $priorities);
 }
 /**
  * Returns a new work order status grid.
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid()
 {
     $columns = ['id', 'created_at', 'user_id', 'name', 'color'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (Priority $priority) {
         return ['id' => $priority->id, 'created_at' => $priority->created_at, 'created_by' => $priority->user ? $priority->user->full_name : '<em>System</em>', 'name' => $priority->name, 'color' => $priority->color, 'view_url' => route('maintenance.work-orders.priorities.edit', [$priority->id])];
     };
     return $this->priority->grid($columns, $settings, $transformer);
 }
 /**
  * Deletes the specified priority.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     $priority = $this->priority->model()->findOrFail($id);
     if ($priority->delete()) {
         $message = 'Successfully deleted priority.';
         return redirect()->route('maintenance.work-orders.priorities.index')->withSuccess($message);
     } else {
         $message = 'There was an issue deleting this priority. Please try again.';
         return redirect()->route('maintenance.work-orders.priorities.index')->withErrors($message);
     }
 }
Beispiel #5
0
 /**
  * Creates a new work order from a work request.
  *
  * @param WorkRequest $workRequest
  *
  * @return bool|WorkOrder
  */
 public function createFromWorkRequest(WorkRequest $workRequest)
 {
     /*
      * We'll make sure the work request doesn't already have a
      * work order attached to it before we try and create it
      */
     if (!$workRequest->workOrder) {
         $priority = $this->priority->createDefaultRequested();
         $status = $this->status->createDefaultRequested();
         $workOrder = $this->model();
         $workOrder->status_id = $status->id;
         $workOrder->priority_id = $priority->id;
         $workOrder->request_id = $workRequest->id;
         $workOrder->user_id = $workRequest->user_id;
         $workOrder->subject = $workRequest->subject;
         $workOrder->description = $workRequest->description;
         if ($workOrder->save()) {
             return $workOrder;
         }
     }
     return false;
 }