<?php

namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use App\Http\Requests\StaticInfo\CreateStaticInfoRequest;
use App\Http\Requests\StaticInfo\UpdateStaticInfoRequest;
use App\Http\Resources\StaticInfo\StaticInfoResource;
use App\Services\StaticInfoService;

class StaticInfoController extends Controller
{
    public function __construct(private StaticInfoService $service)
    {

    }

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

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

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

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