events() ->latest('start_date') ->paginate(); return EventResource::collection($events); } public function show(Organisation $organisation, Event $event): JsonResponse { Gate::authorize('view', $event); abort_unless($event->organisation_id === $organisation->id, 404); return $this->success(new EventResource($event->load('organisation'))); } public function store(StoreEventRequest $request, Organisation $organisation): JsonResponse { Gate::authorize('create', [Event::class, $organisation]); $event = $organisation->events()->create($request->validated()); return $this->created(new EventResource($event)); } public function update(UpdateEventRequest $request, Organisation $organisation, Event $event): JsonResponse { Gate::authorize('update', $event); abort_unless($event->organisation_id === $organisation->id, 404); $event->update($request->validated()); return $this->success(new EventResource($event->fresh())); } }