/** * Displays the form for editing the specified event. * * @param string $id * * @return mixed */ public function edit($id) { $event = $this->event->find($id); $apiObject = $this->event->findApiObject($event->api_id); if ($apiObject) { return view('maintenance::events.edit', compact('event', 'apiObject')); } abort(404); }
/** * Returns a new grid instance of all available events. * * @return \Cartalyst\DataGrid\DataGrid */ public function grid() { $columns = ['id', 'user_id', 'api_id', 'location_id', 'created_at']; $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11]; $transformer = function (Event $event) { $apiObject = $this->event->findApiObject($event->api_id); if ($apiObject) { $startDate = new \DateTime($apiObject->start); $endDate = new \DateTime($apiObject->end); // If the event is all day, we'll format the dates differently. if ($apiObject->all_day) { $start = $startDate->format('Y-m-d'); $end = $endDate->format('Y-m-d'); } else { $start = $startDate->format('Y-m-d h:i:s'); $end = $endDate->format('Y-m-d h:i:s'); } return ['title' => $apiObject->title, 'location' => $event->location ? $event->location->trail : null, 'start' => $start, 'end' => $end, 'view_url' => route('maintenance.events.show', [$event->id])]; } return null; }; return $this->event->grid($columns, $settings, $transformer); }