<?php

namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreEtabProfRequest;
use App\Http\Resources\EtabProfResource;
use App\Models\EtabProf;
use Illuminate\Http\Request;

class EtabProfController extends Controller
{
    public function index()
    {
        $etabProfs = EtabProf::all();
        return EtabProfResource::collection($etabProfs);
    }

    public function store(StoreEtabProfRequest $request)
    {
        $etabProf = EtabProf::create($request->validated());
        return new EtabProfResource($etabProf);
    }

    public function show(EtabProf $etabProf)
    {
        return new EtabProfResource($etabProf);
    }

    public function update(StoreEtabProfRequest $request, EtabProf $etabProf)
    {
        $etabProf->update($request->validated());
        return new EtabProfResource($etabProf);
    }

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