<?php

namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreEtabAxeRequest;
use App\Http\Resources\EtabAxeResource;
use App\Models\EtabAxe;
use Illuminate\Http\Request;

class EtabAxeController extends Controller
{
    public function index()
    {
        $etabAxes = EtabAxe::all();
        return EtabAxeResource::collection($etabAxes);
    }

    public function store(StoreEtabAxeRequest $request)
    {
        $etabAxe = EtabAxe::create($request->validated());
        return new EtabAxeResource($etabAxe);
    }

    public function show(EtabAxe $etabAxe)
    {
        return new EtabAxeResource($etabAxe);
    }

    public function update(StoreEtabAxeRequest $request, EtabAxe $etabAxe)
    {
        $etabAxe->update($request->validated());
        return new EtabAxeResource($etabAxe);
    }

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