allowedFilters(['id', 'currency_code', 'user_id']) ->allowedIncludes($this->allowedIncludes(self::INCLUDES)) ->allowedSorts(['id', 'created_at', 'updated_at', 'currency_code']) ->simplePaginate(request('per_page', 15)); // Return the credits as a JSON response return CreditResource::collection($credits); } /** * Create a new credit */ public function store(CreateCreditRequest $request) { // Validate and create the credit $credit = Credit::create($request->validated()); // Return the created credit as a JSON response return new CreditResource($credit); } /** * Show a specific credit */ public function show(GetCreditRequest $request, Credit $credit) { $credit = QueryBuilder::for(Credit::class) ->allowedIncludes($this->allowedIncludes(self::INCLUDES)) ->findOrFail($credit->id); // Return the credit as a JSON response return new CreditResource($credit); } /** * Update a specific credit */ public function update(UpdateCreditRequest $request, Credit $credit) { // Validate and update the credit $credit->update($request->validated()); // Return the updated credit as a JSON response return new CreditResource($credit); } /** * Delete a specific credit */ public function destroy(DeleteCreditRequest $request, Credit $credit) { // Delete the credit $credit->delete(); return $this->returnNoContent(); } }