Refactor plant selection logic to filter by user-specific plant ID in various resources

This commit is contained in:
dhanabalan
2025-10-08 18:22:22 +05:30
parent 98dc59538f
commit 5e48861589
6 changed files with 35 additions and 7 deletions

View File

@@ -285,7 +285,11 @@ class SerialValidationResource 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 () {