<?php

namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Requests\StoreChargesPotentielleProfRequest;
use App\Http\Resources\ChargesPotentielleProfResource;
use App\Models\ChargesPotentielleProf;
use Illuminate\Http\Request;

class ChargesPotentielleProfController extends Controller
{
    public function index()
    {
        $chargesPotentielleProfs = ChargesPotentielleProf::all();
        return ChargesPotentielleProfResource::collection($chargesPotentielleProfs);
    }

    public function store(StoreChargesPotentielleProfRequest $request)
    {
        $chargesPotentielleProf = ChargesPotentielleProf::create($request->validated());
        return new ChargesPotentielleProfResource($chargesPotentielleProf);
    }

    public function show(ChargesPotentielleProf $chargesPotentielleProf)
    {
        return new ChargesPotentielleProfResource($chargesPotentielleProf);
    }

    public function update(StoreChargesPotentielleProfRequest $request, ChargesPotentielleProf $chargesPotentielleProf)
    {
        $chargesPotentielleProf->update($request->validated());
        return new ChargesPotentielleProfResource($chargesPotentielleProf);
    }

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