allowedFilters(['id', 'currency_code']) ->allowedIncludes($this->allowedIncludes(self::INCLUDES)) ->allowedSorts(['id', 'created_at', 'updated_at', 'currency_code']) ->simplePaginate(request('per_page', 15)); // Return the tickets as a JSON response return TicketResource::collection($tickets); } /** * Create a new ticket */ public function store(CreateTicketRequest $request) { // Validate and create the ticket $ticket = Ticket::create($request->validated()); // Return the created ticket as a JSON response return new TicketResource($ticket); } /** * Show a specific ticket */ public function show(GetTicketRequest $request, Ticket $ticket) { $ticket = QueryBuilder::for(Ticket::class) ->allowedIncludes($this->allowedIncludes(self::INCLUDES)) ->findOrFail($ticket->id); // Return the ticket as a JSON response return new TicketResource($ticket); } /** * Update a specific ticket */ public function update(UpdateTicketRequest $request, Ticket $ticket) { // Validate and update the ticket $ticket->update($request->validated()); // Return the updated ticket as a JSON response return new TicketResource($ticket); } /** * Delete a specific ticket */ public function destroy(DeleteTicketRequest $request, Ticket $ticket) { // Delete the ticket $ticket->delete(); return $this->returnNoContent(); } }