From 6770aaa25a1bd5382cd18675ce8710036ae7cee6 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 7 Nov 2025 15:21:20 +0530 Subject: [PATCH] Refactor plant selection logic in InvoiceValidationResource to improve readability and maintainability --- .../Resources/InvoiceValidationResource.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/Filament/Resources/InvoiceValidationResource.php b/app/Filament/Resources/InvoiceValidationResource.php index 80a54d6..55d45bf 100644 --- a/app/Filament/Resources/InvoiceValidationResource.php +++ b/app/Filament/Resources/InvoiceValidationResource.php @@ -306,20 +306,20 @@ 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(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 () { - return optional(InvoiceValidation::latest()->first())->plant_id; - }) - ->afterStateUpdated(function ($state, callable $set, callable $get) { - $set('invoice_serial_number', null); - }) - ->reactive(), + // ->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 () { + return optional(InvoiceValidation::latest()->first())->plant_id; + }) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $set('invoice_serial_number', null); + }) + ->reactive(), FileUpload::make('invoice_serial_number') ->label('Invoice Serial Number')