Refactor plant selection options across multiple resources to display plants based on the authenticated user's plant ID, ensuring users only see relevant options.
This commit is contained in:
@@ -50,6 +50,10 @@ class QualityValidationResource extends Resource
|
||||
Forms\Components\Select::make('plant_id')
|
||||
->relationship('plant', 'name')
|
||||
->reactive()
|
||||
->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();
|
||||
})
|
||||
->afterStateUpdated(function (callable $set, callable $get, $state) {
|
||||
$set('item_id', null);
|
||||
$set('line_id', null);
|
||||
|
||||
Reference in New Issue
Block a user