<?php

namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use App\Http\Requests\Services\CreateServicesRequest;
use App\Http\Requests\Services\UpdateServicesRequest;
use App\Http\Resources\Services\ServicesResource;
use App\Services\ServicesService;

class ServicesController extends Controller
{
    public function __construct(private ServicesService $service)
    {

    }

    public function getAll()
    {
        $data = $this->service->getAll();
        $response = ServicesResource::collection($data);
        return response()->json($response);
    }

    public function create(CreateServicesRequest $request)
    {
        $data = $this->service->create($request->validated());
        return response()->json($data);
    }

    public function update(UpdateServicesRequest $request)
    {
        $data = $this->service->updateServices($request->id, $request->validated());
        return response()->json($data);
    }

    public function delete($id)
    {
        $data = $this->service->delete($id);
        return response()->json($data);
    }
}