Added disabled function when record exist #394
@@ -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();
|
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 () {
|
->default(function () {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$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');
|
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
@@ -88,6 +90,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
|
|
||||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('machine_id', null);
|
$set('machine_id', null);
|
||||||
if (! $get('work_group_master_id')) {
|
if (! $get('work_group_master_id')) {
|
||||||
@@ -164,6 +167,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->where('work_group_master_id', $workGroupId)
|
->where('work_group_master_id', $workGroupId)
|
||||||
->pluck('work_center', 'id');
|
->pluck('work_center', 'id');
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if (! $get('plant_id') || ! $get('line_id') || ! $get('work_group_master_id')) {
|
if (! $get('plant_id') || ! $get('line_id') || ! $get('work_group_master_id')) {
|
||||||
$set('machine_id', null);
|
$set('machine_id', null);
|
||||||
@@ -180,6 +184,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->searchable()
|
->searchable()
|
||||||
// ->preload()
|
// ->preload()
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin')))
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
@@ -199,6 +204,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
])
|
])
|
||||||
->reactive()
|
->reactive()
|
||||||
// ->preload()
|
// ->preload()
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin')))
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user