Refactor plant selection logic to filter by user-specific plant ID in various resources
This commit is contained in:
@@ -306,7 +306,11 @@ 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(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 () {
|
||||
@@ -623,7 +627,11 @@ class InvoiceValidationResource extends Resource
|
||||
->form([
|
||||
|
||||
Select::make('plant_id')
|
||||
->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
||||
// ->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 () {
|
||||
|
||||
Reference in New Issue
Block a user