allowedFilters(['quantity', 'price', 'expires_at', 'subscription_id', 'status']) ->allowedIncludes($this->allowedIncludes(self::INCLUDES)) ->allowedSorts(['id', 'created_at', 'updated_at', 'expires_at', 'status']) ->simplePaginate(request('per_page', 15)); // Return the services as a JSON response return ServiceResource::collection($services); } /** * Create a new service */ public function store(CreateServiceRequest $request) { // Validate and create the service $service = Service::create($request->validated()); // Return the created service as a JSON response return new ServiceResource($service); } /** * Show a specific service */ public function show(GetServiceRequest $request, Service $service) { $service = QueryBuilder::for(Service::class) ->allowedIncludes($this->allowedIncludes(self::INCLUDES)) ->findOrFail($service->id); // Return the service as a JSON response return new ServiceResource($service); } /** * Update a specific service */ public function update(UpdateServiceRequest $request, Service $service) { // Validate and update the service $service->update($request->validated()); // Return the updated service as a JSON response return new ServiceResource($service); } /** * Delete a specific service */ public function destroy(DeleteServiceRequest $request, Service $service) { // Delete the service $service->delete(); return $this->returnNoContent(); } }