<?php

namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreProgressionRequest;
use App\Http\Resources\ProgressionResource;
use App\Models\Progression;
use Illuminate\Http\Request;

class ProgressionController extends Controller
{
    public function index()
    {
        $progressions = Progression::all();
        return ProgressionResource::collection($progressions);
    }

    public function store(StoreProgressionRequest $request)
    {
        $progression = Progression::create($request->validated());
        return new ProgressionResource($progression);
    }

    public function show(Progression $progression)
    {
        return new ProgressionResource($progression);
    }

    public function update(StoreProgressionRequest $request, Progression $progression)
    {
        $progression->update($request->validated());
        return new ProgressionResource($progression);
    }

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