diff --git a/app/Filament/Resources/ItemResource.php b/app/Filament/Resources/ItemResource.php index a11dd21..df3a7ed 100644 --- a/app/Filament/Resources/ItemResource.php +++ b/app/Filament/Resources/ItemResource.php @@ -293,20 +293,18 @@ class ItemResource extends Resource ]) ->query(function ($query, array $data) { // Hide all records initially if no filters are applied - if ( - empty($data['Plant']) && - empty($data['code']) && - empty($data['description']) && - empty($data['uom']) && - empty($data['category']) && - empty($data['created_from']) && - empty($data['created_to']) - ) { + if (empty($data['Plant']) && empty($data['code']) && empty($data['description']) && empty($data['uom']) && empty($data['category']) && empty($data['created_from']) && empty($data['created_to'])) { return $query->whereRaw('1 = 0'); } if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null $query->where('plant_id', $data['Plant']); + } else { + $userHas = Filament::auth()->user()->plant_id; + + if ($userHas && strlen($userHas) > 0) { + return $query->whereRaw('1 = 0'); + } } if (! empty($data['code'])) { @@ -338,6 +336,17 @@ class ItemResource extends Resource if (! empty($data['Plant'])) { $indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name'); + } else { + $userHas = Filament::auth()->user()->plant_id; + + if ($userHas && strlen($userHas) > 0) { + // Notification::make() + // ->title('Choose plant to filter records.') + // ->danger() + // ->seconds(1) + // ->send(); + return 'Plant: Choose plant to filter records.'; + } } if (! empty($data['code'])) { diff --git a/app/Filament/Resources/StickerMasterResource.php b/app/Filament/Resources/StickerMasterResource.php index b111059..86955cd 100644 --- a/app/Filament/Resources/StickerMasterResource.php +++ b/app/Filament/Resources/StickerMasterResource.php @@ -649,19 +649,18 @@ class StickerMasterResource extends Resource ]) ->query(function ($query, array $data) { // Hide all records initially if no filters are applied - if ( - empty($data['Plant']) && - empty($data['item_id']) && - empty($data['material_type']) && - empty($data['panel_box_code']) && - empty($data['created_from']) && - empty($data['created_to']) - ) { + if (empty($data['Plant']) && empty($data['item_id']) && empty($data['material_type']) && empty($data['panel_box_code']) && empty($data['created_from']) && empty($data['created_to'])) { return $query->whereRaw('1 = 0'); } if (! empty($data['Plant'])) { // $plant = $data['Plant'] ?? null $query->where('plant_id', $data['Plant']); + } else { + $userHas = Filament::auth()->user()->plant_id; + + if ($userHas && strlen($userHas) > 0) { + return $query->whereRaw('1 = 0'); + } } if (! empty($data['item_id'])) { @@ -690,6 +689,17 @@ class StickerMasterResource extends Resource if (! empty($data['Plant'])) { $indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name'); + } else { + $userHas = Filament::auth()->user()->plant_id; + + if ($userHas && strlen($userHas) > 0) { + // Notification::make() + // ->title('Choose plant to filter records.') + // ->danger() + // ->seconds(1) + // ->send(); + return 'Plant: Choose plant to filter records.'; + } } if (! empty($data['item_id'])) { @@ -878,9 +888,9 @@ class StickerMasterResource extends Resource $disk->makeDirectory($directory, 0755, true); } - // $fullPath = Storage::disk('local')->path($directory); + // $fullPath = Storage::disk('local')->path($directory); - // $directory = "uploads/PartValidation/{$plantCode}"; + // $directory = "uploads/PartValidation/{$plantCode}"; // $disk = Storage::disk('local'); // if (! $disk->exists($directory)) {