Refactor plant selection logic in InvoiceValidationResource to improve readability and maintainability
This commit is contained in:
@@ -306,20 +306,20 @@ class InvoiceValidationResource extends Resource
|
||||
->label('Import Serial Invoice')
|
||||
->form([
|
||||
Select::make('plant_id')
|
||||
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('invoice_serial_number', null);
|
||||
})
|
||||
->reactive(),
|
||||
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->label('Select Plant')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('invoice_serial_number', null);
|
||||
})
|
||||
->reactive(),
|
||||
|
||||
FileUpload::make('invoice_serial_number')
|
||||
->label('Invoice Serial Number')
|
||||
|
||||
Reference in New Issue
Block a user