From ece893ae84d49a28a070bfaae8880ab97af61486 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 29 Sep 2025 18:21:13 +0530 Subject: [PATCH] Refactor plant selection options in InvoiceFinder to filter by authenticated user's plant ID. --- app/Filament/Pages/InvoiceFinder.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Filament/Pages/InvoiceFinder.php b/app/Filament/Pages/InvoiceFinder.php index e9211cb..1a02615 100644 --- a/app/Filament/Pages/InvoiceFinder.php +++ b/app/Filament/Pages/InvoiceFinder.php @@ -5,6 +5,7 @@ namespace App\Filament\Pages; use App\Models\LocatorInvoiceValidation; use App\Models\PalletValidation; use App\Models\Plant; +use Filament\Facades\Filament; use Illuminate\Support\Facades\Auth; use Filament\Forms\Contracts\HasForms; use Filament\Forms\Concerns\InteractsWithForms; @@ -41,8 +42,12 @@ class InvoiceFinder extends Page implements HasForms Section::make('') // You can give your section a title or leave it blank ->schema([ Select::make('plant_id') - ->options(Plant::pluck('name', 'id')) ->label('Plant') + //->options(Plant::pluck('name', 'id')) + ->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(); + }) ->reactive() ->required(), TextInput::make('scan_invoice')