<?php

namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreReformeRequest;
use App\Http\Resources\ReformeResource;
use App\Models\Reforme;
use Illuminate\Http\Request;

class ReformeController extends Controller
{
    public function index()
    {
        $reformes = Reforme::all();
        return ReformeResource::collection($reformes);
    }

    public function store(StoreReformeRequest $request)
    {
        $reforme = Reforme::create($request->validated());
        return new ReformeResource($reforme);
    }

    public function show(Reforme $reforme)
    {
        return new ReformeResource($reforme);
    }

    public function update(StoreReformeRequest $request, Reforme $reforme)
    {
        $reforme->update($request->validated());
        return new ReformeResource($reforme);
    }

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