コード例 #1
0
 /**
  * Creates a new report on the specified event.
  *
  * @param ReportRequest $request
  * @param int|string    $eventId
  *
  * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
  */
 public function store(ReportRequest $request, $eventId)
 {
     $report = $this->event->createReport($request, $eventId);
     if ($report) {
         $message = "Successfully created event report.";
         return redirect()->route('maintenance.events.show', [$eventId, '#tab-report'])->withSuccess($message);
     } else {
         $message = "There was an issue creating a report for this event. Please try again.";
         return redirect()->route('maintenance.events.show', [$eventId, '#tab-report'])->withErrors($message);
     }
 }
コード例 #2
0
 /**
  * Returns the specified events recurrences.
  *
  * @param int|string $id
  *
  * @return array|\Cartalyst\DataGrid\DataGrid
  */
 public function gridRecurrences($id)
 {
     $events = $this->event->getRecurrencesByApiId($id);
     if ($events) {
         $columns = ['start', 'end'];
         $settings = ['sort' => 'start', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
         return $this->event->newGrid($events, $columns, $settings);
     }
     return [];
 }
コード例 #3
0
ファイル: Controller.php プロジェクト: redknitin/maintenance
 /**
  * Deletes the specified event.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     if ($this->event->delete($id)) {
         $message = 'Successfully deleted event';
         return redirect()->route('maintenance.events.index')->withSuccess($message);
     } else {
         $message = 'There was an error trying to delete this event. Please try again.';
         return redirect()->route('maintenance.events.show', [$id])->withErrors($message);
     }
 }
コード例 #4
0
 /**
  * Returns a new grid instance of all available events.
  *
  * @param int|string $eventableId
  *
  * @return \Cartalyst\DataGrid\DataGrid
  */
 public function grid($eventableId)
 {
     $columns = ['events.id', 'events.user_id', 'events.api_id', 'events.location_id', 'events.created_at'];
     $settings = ['sort' => 'created_at', 'direction' => 'desc', 'threshold' => 10, 'throttle' => 11];
     $transformer = function (Event $event) use($eventableId) {
         $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($this->routes['show'], [$eventableId, $event->id])];
         }
         return null;
     };
     return $this->getEventableRepository()->gridEvents($eventableId, $columns, $settings, $transformer);
 }