Update OrdenProduccionResource.php
This commit is contained in:
@@ -68,9 +68,21 @@ class OrdenProduccionResource extends Resource
|
||||
|
||||
Select::make('tela_id')
|
||||
->label('Tela asociada')
|
||||
->options(fn () => \App\Models\Tela::where('metros_disponibles', '>', 0)->pluck('codigo', 'id')->toArray())
|
||||
->options(function () {
|
||||
// Obtener todas las telas y calcular disponible
|
||||
$telas = \App\Models\Tela::all();
|
||||
$opciones = [];
|
||||
|
||||
foreach ($telas as $tela) {
|
||||
$disponible = $tela->metros_disponibles;
|
||||
if ($disponible > 0) {
|
||||
$opciones[$tela->id] = $tela->codigo . ' (Disponible: ' . number_format($disponible, 2) . ' m)';
|
||||
}
|
||||
}
|
||||
|
||||
return $opciones;
|
||||
})
|
||||
->searchable()
|
||||
->preload()
|
||||
->reactive()
|
||||
->afterStateUpdated(function ($state, $set, $get) {
|
||||
if ($state) {
|
||||
|
||||
Reference in New Issue
Block a user