<?php

namespace App\Http\Controllers\Filament;

use App\Http\Controllers\Controller;
use App\Models\TrasladoPrenda;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class TrasladoPrendaController extends Controller
{
    use AuthorizesRequests;

    public function markReceived(Request $request, TrasladoPrenda $traslado)
    {

        $data = $request->validate([
            'cantidad_recibida' => ['nullable', 'integer', 'min:0'],
            'prendas_defectuosas' => ['nullable', 'integer', 'min:0'],
            'reparaciones' => ['nullable', 'integer', 'min:0'],
            'saldos' => ['nullable', 'integer', 'min:0'],
        ]);

        $userId = Auth::id();

        $traslado->markAsReceived($data, $userId);

        return redirect()->back()->with('success', 'Traslado marcado como recibido');
    }
}
