From 17047618448800181acd7dc9870061f399a75cf6 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 26 Feb 2026 20:18:18 +0530 Subject: [PATCH] Updated rule parameters on unique item and setting default value and removed visible hide function --- .../ProductCharacteristicsMasterResource.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Filament/Resources/ProductCharacteristicsMasterResource.php b/app/Filament/Resources/ProductCharacteristicsMasterResource.php index c4831e9..d62b000 100644 --- a/app/Filament/Resources/ProductCharacteristicsMasterResource.php +++ b/app/Filament/Resources/ProductCharacteristicsMasterResource.php @@ -86,7 +86,8 @@ class ProductCharacteristicsMasterResource extends Resource ->where('line_id', $get('line_id')) ->where('work_group_master_id', $get('work_group_master_id')) ->where('machine_id', $get('machine_id')) - // ->where('characteristics_type', $get('characteristics_type')) + ->where('characteristics_type', $get('characteristics_type')) + ->where('name', $get('name')) ->ignore($get('id')); }, // function (callable $get): Closure { @@ -227,6 +228,11 @@ class ProductCharacteristicsMasterResource extends Resource // ->preload() ->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin'))) ->afterStateUpdated(function ($state, callable $set) { + if ($state == 'Visual') { + $set('lower', 0); + $set('middle', 0); + $set('upper', 0); + } $set('updated_by', Filament::auth()->user()?->name); }) ->required(), @@ -259,7 +265,8 @@ class ProductCharacteristicsMasterResource extends Resource $set('middle', ($state + $get('upper')) / 2); $set('updated_by', Filament::auth()->user()?->name); }) - ->visible(fn (callable $get) => $get('inspection_type') == 'Value'), + // ->visible(fn (callable $get) => $get('inspection_type') == 'Value') + ->readOnly(fn (callable $get) => $get('inspection_type') != 'Value'), Forms\Components\TextInput::make('upper') ->label('Upper') ->numeric() @@ -272,7 +279,8 @@ class ProductCharacteristicsMasterResource extends Resource $set('middle', ($get('lower') + $state) / 2); $set('updated_by', Filament::auth()->user()?->name); }) - ->visible(fn (callable $get) => $get('inspection_type') == 'Value'), + // ->visible(fn (callable $get) => $get('inspection_type') == 'Value') + ->readOnly(fn (callable $get) => $get('inspection_type') != 'Value'), Forms\Components\TextInput::make('middle') ->label('Middle') ->readOnly() @@ -295,8 +303,8 @@ class ProductCharacteristicsMasterResource extends Resource ->dehydrateStateUsing(fn ($state, Get $get) => ($get('lower') + $get('upper')) / 2) ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }) - ->visible(fn (callable $get) => $get('inspection_type') == 'Value'), + }), + // ->visible(fn (callable $get) => $get('inspection_type') == 'Value'), Forms\Components\Hidden::make('created_by') ->label('Created By') ->default(Filament::auth()->user()?->name),