/** * Get the crew list, ordered by crew role. * @return array */ public function getCrewListAttribute() { $core = []; $general = []; $guest = []; // Get the BTS crew foreach ($this->crew()->orderBy('event_crew.name', 'ASC')->orderBy('users.surname', 'ASC')->orderBy('users.forename', 'ASC')->get() as $crew) { if ($crew->name) { @($core[$crew->name][] = $crew); } else { $general[] = $crew; } } // Get any guest crew if ($this->isSocial()) { $guest = EventCrew::where('event_id', $this->id)->whereNull('user_id')->get(); } return $core + (empty($general) ? [] : ['General Crew' => $general]) + (count($guest) ? ['Guest' => $guest] : []); }
/** * Delete a crew role. * @param \App\Http\Requests\GenericRequest $request * @param \App\Event $event * @return mixed */ private function update_DeleteCrew(GenericRequest $request, Event $event) { // Get the event crew $crew = EventCrew::where('event_id', $event->id)->where('id', $request->get('id'))->first(); if (!$crew) { return $this->ajaxError("Couldn't find the crew entry", 404); } // Delete $crew->delete(); Flash::success('Crew role deleted'); return Response::json(true); }