From 0e1accaaec0ff0436158d26445ec4158ac244e5c Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 4 Mar 2026 15:55:03 +0530 Subject: [PATCH] loaded plants against user rights in production quantity page --- app/Filament/Pages/ProductionQuantityPage.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/Filament/Pages/ProductionQuantityPage.php b/app/Filament/Pages/ProductionQuantityPage.php index 1386d3f..99def3c 100644 --- a/app/Filament/Pages/ProductionQuantityPage.php +++ b/app/Filament/Pages/ProductionQuantityPage.php @@ -163,11 +163,15 @@ class ProductionQuantityPage extends Page implements HasForms return $form ->statePath('filters') ->schema([ - Select::make('plant_id') - ->options(Plant::pluck('name', 'id')) + // ->options(Plant::pluck('name', 'id')) ->label('Plant') ->reactive() + ->options(function (callable $get) { + $userHas = Filament::auth()->user()->plant_id; + + return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); + }) ->required() ->columnSpan(1) ->default(function () { @@ -419,13 +423,13 @@ class ProductionQuantityPage extends Page implements HasForms $machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->first(); - if (!$machinenotAgaPlant) { + if (! $machinenotAgaPlant) { Notification::make() ->title('Unknown WorkCenter') - ->body("Work Center not found") + ->body('Work Center not found') ->danger() ->send(); - $this->form->fill([ + $this->form->fill([ 'plant_id' => $this->pId, 'machine_id' => $this->mNam, 'block_name' => $this->bNam, @@ -440,9 +444,9 @@ class ProductionQuantityPage extends Page implements HasForms // 'operator_id'=> $operatorName, 'recent_qr' => $this->recQr, ]); + return; - } - else if (!$machineAgaPlant) { + } elseif (! $machineAgaPlant) { Notification::make() ->title('Unknown WorkCenter') ->body("Work Center not found against plant code $PlaCo") @@ -464,20 +468,20 @@ class ProductionQuantityPage extends Page implements HasForms // 'operator_id'=> $operatorName, 'recent_qr' => $this->recQr, ]); + return; } $rec = ProductionQuantity::where('plant_id', $plantId)->where('machine_id', $machineAgaPlant->id)->latest()->first(); - if($rec) - { + if ($rec) { $item = Item::where('id', $rec->item_id)->where('plant_id', $plantId)->first(); $itemCode = $item?->code ?? ''; $serialNo = $rec->serial_number ?? ''; - $this->recQr = $itemCode . ' | ' . $serialNo; + $this->recQr = $itemCode.' | '.$serialNo; } @@ -1125,7 +1129,6 @@ class ProductionQuantityPage extends Page implements HasForms $iCode = trim($splits[0]); $sNumber = isset($splits[1]) ? trim($splits[1]) : null; - if (! ctype_alnum($iCode)) { $this->form->fill([ -- 2.49.1