diff --git a/app/Filament/Resources/ProductCharacteristicsMasterResource.php b/app/Filament/Resources/ProductCharacteristicsMasterResource.php index 6cc2473..da9a4f5 100644 --- a/app/Filament/Resources/ProductCharacteristicsMasterResource.php +++ b/app/Filament/Resources/ProductCharacteristicsMasterResource.php @@ -49,6 +49,7 @@ class ProductCharacteristicsMasterResource extends Resource return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); }) + ->disabled(fn (Get $get) => ! empty($get('id'))) ->default(function () { $userHas = Filament::auth()->user()->plant_id; @@ -72,6 +73,7 @@ class ProductCharacteristicsMasterResource extends Resource return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id'); }) + ->disabled(fn (Get $get) => ! empty($get('id'))) ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) @@ -88,6 +90,7 @@ class ProductCharacteristicsMasterResource extends Resource return Line::where('plant_id', $plantId)->pluck('name', 'id'); }) + ->disabled(fn (Get $get) => ! empty($get('id'))) ->afterStateUpdated(function ($state, callable $set, callable $get) { $set('machine_id', null); if (! $get('work_group_master_id')) { @@ -164,6 +167,7 @@ class ProductCharacteristicsMasterResource extends Resource ->where('work_group_master_id', $workGroupId) ->pluck('work_center', 'id'); }) + ->disabled(fn (Get $get) => ! empty($get('id'))) ->afterStateUpdated(function ($state, callable $set, callable $get) { if (! $get('plant_id') || ! $get('line_id') || ! $get('work_group_master_id')) { $set('machine_id', null); @@ -180,6 +184,7 @@ class ProductCharacteristicsMasterResource extends Resource ->reactive() ->searchable() // ->preload() + ->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin'))) ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) @@ -199,6 +204,7 @@ class ProductCharacteristicsMasterResource extends Resource ]) ->reactive() // ->preload() + ->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin'))) ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); })