Refactor plant selection options by authenticated user's plant ID.
This commit is contained in:
@@ -54,10 +54,14 @@ class UploadSerialLocator extends Page implements HasForms
|
||||
Section::make('') // You can give your section a title or leave it blank
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id'))
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
->required()
|
||||
//->options(Plant::pluck('name', 'id'))
|
||||
->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();
|
||||
})
|
||||
->disabled(fn (Get $get) => $get('scan_serial_number') || $get('scan_locator')) //!empty($get('scan_serial_number'))
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('scan_serial_number', null);
|
||||
|
||||
Reference in New Issue
Block a user