up
This commit is contained in:
@@ -14,6 +14,35 @@ class EditConfeccion extends EditRecord
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
|
||||
Actions\Action::make('agregarRecepcion')
|
||||
->label('Agregar recepción')
|
||||
->modalHeading('Agregar Recepción')
|
||||
->form([
|
||||
Forms\Components\DatePicker::make('fecha_recepcion')->default(now())->required(),
|
||||
Forms\Components\TextInput::make('cantidad')->numeric()->required()->minValue(1),
|
||||
Forms\Components\Textarea::make('notas'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$record = $this->getRecord();
|
||||
|
||||
\App\Models\Recepcion::create([
|
||||
'referencia_type' => \App\Models\Confeccion::class,
|
||||
'referencia_id' => $record->id,
|
||||
'cantidad' => (int) $data['cantidad'],
|
||||
'fecha_recepcion' => $data['fecha_recepcion'],
|
||||
'notas' => $data['notas'] ?? null,
|
||||
]);
|
||||
|
||||
\Filament\Notifications\Notification::make()
|
||||
->success()
|
||||
->title('Recepción registrada')
|
||||
->body('La recepción se creó correctamente.')
|
||||
->send();
|
||||
|
||||
// Refrescar la página para ver cambios
|
||||
$this->redirect($this->getUrl());
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user