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:
dhanabalan
2025-09-29 16:35:55 +05:30
parent a4afe2f3c7
commit a9803f927f
34 changed files with 208 additions and 32 deletions

View File

@@ -66,6 +66,10 @@ class InvoiceValidationResource extends Resource
// ->nullable(),
->reactive()
->columnSpan(1)
->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();
})
->default(function () {
return optional(InvoiceValidation::latest()->first())->plant_id;
})