This commit is contained in:
Lizandro Guarnizo
2026-01-29 17:16:19 -05:00
parent 35f56cbbe0
commit 107f7198d2
2 changed files with 24 additions and 44 deletions
@@ -11,6 +11,7 @@ class AjustesRelationManager extends RelationManager
{
protected static string $relationship = 'ajustes';
protected static ?string $recordTitleAttribute = 'id';
protected static ?string $title = 'Arreglos';
public function table(Tables\Table $table): Tables\Table
{
@@ -25,18 +26,29 @@ class AjustesRelationManager extends RelationManager
])
->filters([])
->headerActions([
Tables\Actions\CreateAction::make()->form([
\Filament\Forms\Components\TextInput::make('cantidad')->numeric()->required()->minValue(1),
\Filament\Forms\Components\Textarea::make('notas'),
])->action(function (array $data) {
$owner = $this->getOwnerRecord();
try {
$owner->registerArreglo((int)$data['cantidad'], $data['notas'] ?? null, auth()->id() ?? null);
\Filament\Notifications\Notification::make()->success()->title('Arreglo registrado')->send();
} catch (\Throwable $e) {
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
}
}),
Tables\Actions\CreateAction::make()
->label('Registrar arreglo')
->modalHeading('Registrar Arreglo')
->form([
\Filament\Forms\Components\TextInput::make('cantidad')
->label('Cantidad')
->numeric()
->required()
->minValue(1)
->helperText('Prendas que llegaron defectuosas y necesitan reparación'),
\Filament\Forms\Components\Textarea::make('notas'),
])
->action(function (array $data) {
$owner = $this->getOwnerRecord();
try {
$owner->registerArreglo((int)$data['cantidad'], $data['notas'] ?? null, auth()->id() ?? null);
\Filament\Notifications\Notification::make()->success()->title('Arreglo registrado')->send();
} catch (\Illuminate\Validation\ValidationException $e) {
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->validator->errors()->first())->send();
} catch (\Throwable $e) {
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
}
}),
])
->actions([])
->bulkActions([]);