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:
@@ -52,6 +52,10 @@ class ReworkLocatorInvoiceValidationResource extends Resource
|
||||
->relationship('plant', 'name')
|
||||
->disabled(fn (Get $get) => $get('rework_type'))
|
||||
->required()
|
||||
->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 ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if ($plantId)
|
||||
|
||||
Reference in New Issue
Block a user