up
This commit is contained in:
+25
-13
@@ -24,19 +24,31 @@ class CobrosRelationManager extends RelationManager
|
||||
])
|
||||
->filters([])
|
||||
->headerActions([
|
||||
Tables\Actions\CreateAction::make()->form([
|
||||
\Filament\Forms\Components\TextInput::make('cantidad')->numeric()->required()->minValue(1),
|
||||
\Filament\Forms\Components\TextInput::make('valor')->numeric()->required()->minValue(0),
|
||||
\Filament\Forms\Components\Textarea::make('notas'),
|
||||
])->action(function (array $data) {
|
||||
$owner = $this->getOwnerRecord();
|
||||
try {
|
||||
$owner->registerCobro((int)$data['cantidad'], (float)$data['valor'], $data['notas'] ?? null, auth()->id() ?? null);
|
||||
\Filament\Notifications\Notification::make()->success()->title('Cobro registrado')->send();
|
||||
} catch (\Throwable $e) {
|
||||
\Filament\Notifications\Notification::make()->danger()->title('Error')->body($e->getMessage())->send();
|
||||
}
|
||||
}),
|
||||
Tables\Actions\CreateAction::make()
|
||||
->label('Agregar cobro')
|
||||
->form([
|
||||
\Filament\Forms\Components\TextInput::make('cantidad')
|
||||
->numeric()
|
||||
->required()
|
||||
->minValue(1)
|
||||
->helperText('Prendas que NO llegaron y se cobran a la tintorería'),
|
||||
\Filament\Forms\Components\TextInput::make('valor')
|
||||
->numeric()
|
||||
->required()
|
||||
->minValue(0)
|
||||
->label('Valor a descontar'),
|
||||
\Filament\Forms\Components\Textarea::make('notas'),
|
||||
])->action(function (array $data) {
|
||||
$owner = $this->getOwnerRecord();
|
||||
try {
|
||||
$owner->registerCobro((int)$data['cantidad'], (float)$data['valor'], $data['notas'] ?? null, auth()->id() ?? null);
|
||||
\Filament\Notifications\Notification::make()->success()->title('Cobro 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([]);
|
||||
|
||||
Reference in New Issue
Block a user