authorize('viewAny', HistoryEntry::class); $entries = $client->historyEntries() ->with(['author', 'updatedBy', 'entryType']) ->orderByDesc('created_at') ->get(); return HistoryEntryResource::collection($entries); } public function store( CreateHistoryEntryRequest $request, Client $client, CreateHistoryEntryAction $action ): JsonResponse { $this->authorize('create', HistoryEntry::class); $entry = $action->handle($client, HistoryEntryData::fromCreateRequest($request), $request->user()); return HistoryEntryResource::make($entry->load(['author', 'entryType']))->response()->setStatusCode(201); } public function update( UpdateHistoryEntryRequest $request, HistoryEntry $historyEntry, UpdateHistoryEntryAction $action ): HistoryEntryResource { $this->authorize('update', $historyEntry); $updated = $action->handle($historyEntry, HistoryEntryData::fromUpdateRequest($request), $request->user()); return HistoryEntryResource::make($updated->load(['author', 'updatedBy', 'entryType'])); } public function destroy(HistoryEntry $historyEntry): JsonResponse { $this->authorize('delete', $historyEntry); $historyEntry->delete(); return response()->json(null, 204); } }