<?php

namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreStatutRequest;
use App\Http\Resources\StatutResource;
use App\Models\Statut;
use Illuminate\Http\Request;

class StatutController extends Controller
{
    public function index()
    {
        $statuts = Statut::all();
        return StatutResource::collection($statuts);
    }

    public function store(StoreStatutRequest $request)
    {
        $statut = Statut::create($request->validated());
        return new StatutResource($statut);
    }

    public function show(Statut $statut)
    {
        return new StatutResource($statut);
    }

    public function update(StoreStatutRequest $request, Statut $statut)
    {
        $statut->update($request->validated());
        return new StatutResource($statut);
    }

    public function destroy(Statut $statut)
    {
        $statut->delete();
        return response()->json(['message' => 'Statut supprimé'], 200);
    }
}
