<?php

namespace App\Http\Controllers;

use App\Http\Requests\InventarioStoreRequest;
use App\Http\Requests\InventarioUpdateRequest;
use App\Http\Resources\InventarioCollection;
use App\Http\Resources\InventarioResource;
use App\Models\Inventario;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class InventarioController extends Controller
{
    public function index(Request $request): InventarioCollection
    {
        $inventarios = Inventario::all();

        return new InventarioCollection($inventarios);
    }

    public function store(InventarioStoreRequest $request): InventarioResource
    {
        $inventario = Inventario::create($request->validated());

        return new InventarioResource($inventario);
    }

    public function show(Request $request, Inventario $inventario): InventarioResource
    {
        return new InventarioResource($inventario);
    }

    public function update(InventarioUpdateRequest $request, Inventario $inventario): InventarioResource
    {
        $inventario->update($request->validated());

        return new InventarioResource($inventario);
    }

    public function destroy(Request $request, Inventario $inventario): Response
    {
        $inventario->delete();

        return response()->noContent();
    }
}
