<?php

namespace App\Http\Controllers;

use App\Http\Requests\DetalleVentumStoreRequest;
use App\Http\Requests\DetalleVentumUpdateRequest;
use App\Http\Resources\DetalleVentumCollection;
use App\Http\Resources\DetalleVentumResource;
use App\Models\DetalleVenta;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class DetalleVentaController extends Controller
{
    public function index(Request $request): DetalleVentumCollection
    {
        $detalleVenta = DetalleVentum::all();

        return new DetalleVentumCollection($detalleVenta);
    }

    public function store(DetalleVentumStoreRequest $request): DetalleVentumResource
    {
        $detalleVentum = DetalleVentum::create($request->validated());

        return new DetalleVentumResource($detalleVentum);
    }

    public function show(Request $request, DetalleVentum $detalleVentum): DetalleVentumResource
    {
        return new DetalleVentumResource($detalleVentum);
    }

    public function update(DetalleVentumUpdateRequest $request, DetalleVentum $detalleVentum): DetalleVentumResource
    {
        $detalleVentum->update($request->validated());

        return new DetalleVentumResource($detalleVentum);
    }

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

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