Added disabled function when record exist #394

Merged
jothi merged 1 commits from ranjith-dev into master 2026-02-25 05:37:47 +00:00
Showing only changes of commit 076d4a8f68 - Show all commits

View File

@@ -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);
})