From dd84356591f2091dc8c18906d63a90b6a8f2661d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 9 Mar 2026 23:21:10 +0530 Subject: [PATCH 1/2] Updated validation logic on resource page --- .../Resources/ClassCharacteristicResource.php | 518 ++++++++++++------ 1 file changed, 361 insertions(+), 157 deletions(-) diff --git a/app/Filament/Resources/ClassCharacteristicResource.php b/app/Filament/Resources/ClassCharacteristicResource.php index 335304a..d1f68a7 100644 --- a/app/Filament/Resources/ClassCharacteristicResource.php +++ b/app/Filament/Resources/ClassCharacteristicResource.php @@ -21,6 +21,8 @@ use Filament\Tables\Actions\ImportAction; use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; +use Illuminate\Validation\Rule; +use Str; class ClassCharacteristicResource extends Resource { @@ -82,7 +84,7 @@ class ClassCharacteristicResource extends Resource return ClassCharacteristic::where('plant_id', $plantId)->latest()->first()->machine_id ?? null; }) - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->required(), @@ -108,812 +110,1014 @@ class ClassCharacteristicResource extends Resource return ClassCharacteristic::where('plant_id', $plantId)->latest()->first()->item_id ?? null; }) - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->required(), Forms\Components\TextInput::make('aufnr') ->label('AUFNR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->minLength(7) + ->maxLength(10) + ->readOnly(fn (callable $get) => (! $get('plant_id') || ! $get('machine_id') || ! $get('item_id'))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->required(), Forms\Components\TextInput::make('class') ->label('CLASS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) + ->readOnly(fn (callable $get) => (! $get('aufnr'))) ->required(), Forms\Components\TextInput::make('arbid') ->label('ARBID') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => (! $get('class'))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->required(), Forms\Components\TextInput::make('gamng') ->label('GAMNG') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => (! $get('arbid'))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->required(), Forms\Components\TextInput::make('lmnga') ->label('LMNGA') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => (! $get('gamng'))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->required(), Forms\Components\TextInput::make('gernr') ->label('GERNR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->minLength(13) + ->readOnly(fn (callable $get) => (! $get('lmnga'))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) + ->rules([ + function (callable $get) { + return Rule::unique('class_characteristics', 'gernr') + ->where('plant_id', $get('plant_id')) + ->ignore($get('id')); + }, // The GERNR has already been taken. + // function (callable $get): Closure { + // return function (string $attribute, $value, Closure $fail) use ($get) { + // $rework = $get('rework_status'); + // if ($value && Str::contains($value, '.') && $rework == 0) { + // $fail("Rework status should be 'Yes' for rework coil number '{$value}'!"); + // } + // }; + // }, + ]) + ->validationMessages([ + 'unique' => "The 'GERNR' has already been taken.", // The GERNR has already been taken for this plant. + ]) ->required(), Forms\Components\TextInput::make('zz1_cn_bill_ord') ->label('ZZ1 CN BILL ORD') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_amps') ->label('ZMM AMPS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_brand') ->label('ZMM BRAND') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_degreeofprotection') ->label('ZMM DEGREEOFPROTECTION') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_delivery') ->label('ZMM DELIVERY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_dir_rot') ->label('ZMM DIR ROT') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_discharge') ->label('ZMM DISCHARGE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_discharge_max') ->label('ZMM DISCHARGE MAX') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_discharge_min') ->label('ZMM DISCHARGE MIN') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_duty') ->label('ZMM DUTY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_eff_motor') ->label('ZMM EFF MOTOR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_eff_pump') ->label('ZMM EFF PUMP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_frequency') ->label('ZMM FREQUENCY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_head') ->label('ZMM HEAD') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_heading') ->label('ZMM HEADING') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => (! $get('aufnr') || ! $get('gernr'))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_head_max') ->label('ZMM HEAD MAX') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_head_minimum') ->label('ZMM HEAD MINIMUM') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_idx_eff_mtr') ->label('ZMM IDX EFF MTR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_idx_eff_pump') ->label('ZMM IDX EFF PUMP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_kvacode') ->label('ZMM KVACODE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_maxambtemp') ->label('ZMM MAXAMBTEMP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_mincoolingflow') ->label('ZMM MINCOOLINGFLOW') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_motorseries') ->label('ZMM MOTORSERIES') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_motor_model') ->label('ZMM MOTOR MODEL') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_outlet') ->label('ZMM OUTLET') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_phase') ->label('ZMM PHASE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pressure') ->label('ZMM PRESSURE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pumpflowtype') ->label('ZMM PUMPFLOWTYPE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pumpseries') ->label('ZMM PUMPSERIES') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pump_model') ->label('ZMM PUMP MODEL') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_ratedpower') ->label('ZMM RATEDPOWER') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_region') ->label('ZMM REGION') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_servicefactor') ->label('ZMM SERVICEFACTOR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_servicefactormaximumamps') ->label('ZMM SERVICEFACTORMAXIMUMAMPS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_speed') ->label('ZMM SPEED') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_suction') ->label('ZMM SUCTION') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_suctionxdelivery') ->label('ZMM SUCTIONXDELIVERY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_supplysource') ->label('ZMM SUPPLYSOURCE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_temperature') ->label('ZMM TEMPERATURE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_thrustload') ->label('ZMM THRUSTLOAD') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_volts') ->label('ZMM VOLTS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_wire') ->label('ZMM WIRE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_package') ->label('ZMM PACKAGE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pvarrayrating') ->label('ZMM PVARRAYRATING') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isi') ->label('ZMM ISI') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isimotor') ->label('ZMM ISIMOTOR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isipump') ->label('ZMM ISIPUMP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isipumpset') ->label('ZMM ISIPUMPSET') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pumpset_model') ->label('ZMM PUMPSET MODEL') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_stages') ->label('ZMM STAGES') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_headrange') ->label('ZMM HEADRANGE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_overall_efficiency') ->label('ZMM OVERALL EFFICIENCY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_connection') ->label('ZMM CONNECTION') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_min_bore_size') ->label('ZMM MIN BORE SIZE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isireference') ->label('ZMM ISIREFERENCE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_category') ->label('ZMM CATEGORY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_submergence') ->label('ZMM SUBMERGENCE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_capacitorstart') ->label('ZMM CAPACITORSTART') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_capacitorrun') ->label('ZMM CAPACITORRUN') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_inch') ->label('ZMM INCH') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_motor_type') ->label('ZMM MOTOR TYPE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_dismantle_direction') ->label('ZMM DISMANTLE DIRECTION') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_eff_ovrall') ->label('ZMM EFF OVRALL') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_bodymoc') ->label('ZMM BODYMOC') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_rotormoc') ->label('ZMM ROTORMOC') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_dlwl') ->label('ZMM DLWL') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_inputpower') ->label('ZMM INPUTPOWER') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_imp_od') ->label('ZMM IMP OD') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_ambtemp') ->label('ZMM AMBTEMP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_de') ->label('ZMM DE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_dischargerange') ->label('ZMM DISCHARGERANGE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_efficiency_class') ->label('ZMM EFFICIENCY CLASS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_framesize') ->label('ZMM FRAMESIZE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_impellerdiameter') ->label('ZMM IMPELLERDIAMETER') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_insulationclass') ->label('ZMM INSULATIONCLASS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_maxflow') ->label('ZMM MAXFLOW') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_minhead') ->label('ZMM MINHEAD') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_mtrlofconst') ->label('ZMM MTRLOFCONST') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_nde') ->label('ZMM NDE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_powerfactor') ->label('ZMM POWERFACTOR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_tagno') ->label('ZMM TAGNO') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_year') ->label('ZMM YEAR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_laser_name') ->label('ZMM LASER NAME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_logo_cp') ->label('ZMM LOGO CP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_logo_ce') ->label('ZMM LOGO CE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_logo_nsf') ->label('ZMM LOGO NSF') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_beenote') ->label('ZMM BEENOTE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_beenumber') ->label('ZMM BEENUMBER') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_beestar') ->label('ZMM BEESTAR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_codeclass') ->label('ZMM CODECLASS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_colour') ->label('ZMM COLOUR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_grade') ->label('ZMM GRADE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_grwt_pset') ->label('ZMM GRWT PSET') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_grwt_cable') ->label('ZMM GRWT CABLE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_grwt_motor') ->label('ZMM GRWT MOTOR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_grwt_pf') ->label('ZMM GRWT PF') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_grwt_pump') ->label('ZMM GRWT PUMP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isivalve') ->label('ZMM ISIVALVE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_isi_wc') ->label('ZMM ISI WC') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_labelperiod') ->label('ZMM LABELPERIOD') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_length') ->label('ZMM LENGTH') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_license_cml_no') ->label('ZMM LICENSE CML NO') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_mfgmonyr') ->label('ZMM MFGMONYR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_modelyear') ->label('ZMM MODELYEAR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_motoridentification') ->label('ZMM MOTORIDENTIFICATION') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_newt_pset') ->label('ZMM NEWT PSET') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_newt_cable') ->label('ZMM NEWT CABLE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_newt_motor') ->label('ZMM NEWT MOTOR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_newt_pf') ->label('ZMM NEWT PF') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_newt_pump') ->label('ZMM NEWT PUMP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_packtype') ->label('ZMM PACKTYPE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_panel') ->label('ZMM PANEL') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_performance_factor') ->label('ZMM PERFORMANCE_FACTOR') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_pumpidentification') ->label('ZMM PUMPIDENTIFICATION') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_psettype') ->label('ZMM PSETTYPE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_size') ->label('ZMM SIZE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_eff_ttl') ->label('ZMM EFF TTL') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_type') ->label('ZMM TYPE') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('zmm_usp') ->label('ZMM USP') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('mark_status') ->label('MARKED STATUS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\DateTimePicker::make('marked_datetime') ->label('MARKED DATETIME') + ->reactive() ->placeholder('Select Marked DateTime') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) + ->default(now()) ->required(), Forms\Components\TextInput::make('marked_physical_count') ->label('MARKED PHYSICAL COUNT') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default('0') ->required(), Forms\Components\TextInput::make('marked_expected_time') ->label('MARKED EXPECTED TIME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default('0') ->required(), Forms\Components\TextInput::make('marked_by') ->label('MARKED BY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default(Filament::auth()->user()?->name) ->required(), Forms\Components\TextInput::make('man_marked_status') ->label('MANUAL MARKED PHYSICAL COUNT') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! ($get('mark_status') == 'Marked') && ! ($get('motor_marked_status') == 'Marked') && ! ($get('pump_marked_status') == 'Marked') && ! ($get('name_plate_marked_status') == 'Marked')) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default('0') ->required(), Forms\Components\DateTimePicker::make('man_marked_datetime') ->label('MANUAL MARKED DATETIME') + ->reactive() ->placeholder('Select Manual Marked DateTime') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->readOnly(fn (callable $get) => ! ($get('mark_status') == 'Marked') && ! ($get('motor_marked_status') == 'Marked') && ! ($get('pump_marked_status') == 'Marked') && ! ($get('name_plate_marked_status') == 'Marked')) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('man_marked_by') ->label('MANUAL MARKED BY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! ($get('mark_status') == 'Marked') && ! ($get('motor_marked_status') == 'Marked') && ! ($get('pump_marked_status') == 'Marked') && ! ($get('name_plate_marked_status') == 'Marked')) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('motor_marked_status') ->label('MOTOR MARKED STATUS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('motor_marked_physical_count') ->label('MOTOR MARKED PHYSICAL COUNT') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default('0') ->required(), Forms\Components\TextInput::make('motor_expected_time') ->label('MOTOR EXPECTED TIME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default('0') ->required(), Forms\Components\TextInput::make('motor_marked_by') ->label('MOTOR MARKED BY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('pump_marked_status') ->label('PUMP MARKED STATUS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('pump_marked_physical_count') ->label('PUMP MARKED PHYSICAL COUNT') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default('0') ->required(), Forms\Components\TextInput::make('pump_expected_time') ->label('PUMP EXPECTED TIME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default('0') ->required(), Forms\Components\TextInput::make('pump_marked_by') ->label('PUMP MARKED BY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('name_plate_marked_status') ->label('NAME PLATE MARKED STATUS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('name_plate_expected_time') ->label('NAME PLATE EXPECTED TIME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default('0') ->required(), Forms\Components\TextInput::make('name_plate_marked_by') ->label('NAME PLATE MARKED BY') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('motor_pump_pumpset_status') ->label('MOTOR PUMP PUMPSET STATUS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('winded_serial_number') ->label('WINDED SERIAL NUMBER') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('motor_machine_name') ->label('MOTOR MACHINE NAME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'MOTOR', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('pump_machine_name') ->label('PUMP MACHINE NAME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMP', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('name_plate_machine_name') ->label('NAME PLATE MACHINE NAME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('pumpset_machine_name') ->label('PUMPSET MACHINE NAME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->readOnly(fn (callable $get) => ! (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) && ! (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true))) + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('part_validation_1') ->label('PART VALIDATION 1') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('part_validation_2') ->label('PART VALIDATION 2') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('samlight_logged_name') ->label('SAMLIGHT LOGGED NAME') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), Forms\Components\TextInput::make('pending_released_status') ->label('PENDING RELEASED STATUS') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default(0) ->required(), Forms\Components\TextInput::make('has_work_flow_id') ->label('HAS WORK FLOW ID') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + ->reactive() + ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }) ->default(0) -- 2.49.1 From ac9d9cec8dec24de8c2ab012955aacfb07fe2e9d Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 9 Mar 2026 23:47:38 +0530 Subject: [PATCH 2/2] Updated validation on resource file --- .../Resources/ClassCharacteristicResource.php | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/app/Filament/Resources/ClassCharacteristicResource.php b/app/Filament/Resources/ClassCharacteristicResource.php index d1f68a7..f97a157 100644 --- a/app/Filament/Resources/ClassCharacteristicResource.php +++ b/app/Filament/Resources/ClassCharacteristicResource.php @@ -143,6 +143,8 @@ class ClassCharacteristicResource extends Resource Forms\Components\TextInput::make('gamng') ->label('GAMNG') ->reactive() + ->numeric() + ->minValue(1.000) ->readOnly(fn (callable $get) => (! $get('arbid'))) ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -151,6 +153,9 @@ class ClassCharacteristicResource extends Resource Forms\Components\TextInput::make('lmnga') ->label('LMNGA') ->reactive() + ->integer() + ->minValue(1) + ->maxValue(fn (callable $get) => ($get('gamng') ?? 1)) ->readOnly(fn (callable $get) => (! $get('gamng'))) ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); @@ -273,7 +278,8 @@ class ClassCharacteristicResource extends Resource ->readOnly(fn (callable $get) => (! $get('aufnr') || ! $get('gernr'))) ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->required(), Forms\Components\TextInput::make('zmm_head_max') ->label('ZMM HEAD MAX') ->reactive() @@ -1048,8 +1054,37 @@ class ClassCharacteristicResource extends Resource ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); }), - Forms\Components\TextInput::make('motor_pump_pumpset_status') + Forms\Components\Select::make('motor_pump_pumpset_status') ->label('MOTOR PUMP PUMPSET STATUS') + // ->label('Search by PUMPSET Type') + ->nullable() + ->searchable() + ->options(function (callable $get) { + $plantId = $get('plant_id'); + $machineId = $get('machine_id'); + $itemId = $get('item_id'); + + if (empty($plantId) || empty($machineId) || empty($itemId)) { + return []; + } + + if (Str::contains($get('zmm_heading'), 'PRESSURE BOOSTER SYSTEM', ignoreCase: true)) { + return [ + '1' => 'Motor', + '2' => 'Pump', + '3' => 'Pump Set', + '4' => 'Name Plate', + ]; + } elseif (Str::contains($get('zmm_heading'), 'PUMPSET', ignoreCase: true)) { + return [ + '1' => 'Motor', + '2' => 'Pump', + '3' => 'Pump Set', + ]; + } else { + return []; + } + }) ->reactive() ->afterStateUpdated(function (callable $set) { $set('updated_by', Filament::auth()->user()?->name); -- 2.49.1