allowedFilters(['id', 'currency_code', 'user_id', 'status']) ->allowedIncludes($this->allowedIncludes(self::INCLUDES)) ->allowedSorts(['id', 'created_at', 'updated_at', 'currency_code']) ->simplePaginate(request('per_page', 15)); // Return the invoices as a JSON response return InvoiceResource::collection($invoices); } /** * Create a new invoice */ public function store(CreateInvoiceRequest $request) { // Validate and create the invoice $invoice = Invoice::create($request->validated()); // Return the created invoice as a JSON response return new InvoiceResource($invoice); } /** * Show a specific invoice */ public function show(GetInvoiceRequest $request, Invoice $invoice) { $invoice = QueryBuilder::for(Invoice::class) ->allowedIncludes($this->allowedIncludes(self::INCLUDES)) ->findOrFail($invoice->id); // Return the invoice as a JSON response return new InvoiceResource($invoice); } /** * Update a specific invoice */ public function update(UpdateInvoiceRequest $request, Invoice $invoice) { // Validate and update the invoice $invoice->update($request->validated()); // Return the updated invoice as a JSON response return new InvoiceResource($invoice); } /** * Delete a specific invoice */ public function destroy(DeleteInvoiceRequest $request, Invoice $invoice) { // Delete the invoice $invoice->delete(); return $this->returnNoContent(); } }