diff --git a/app/Filament/Resources/MotorTestingMasterResource.php b/app/Filament/Resources/MotorTestingMasterResource.php index 2b6b0c1..c58ae4c 100644 --- a/app/Filament/Resources/MotorTestingMasterResource.php +++ b/app/Filament/Resources/MotorTestingMasterResource.php @@ -13,6 +13,7 @@ use Filament\Facades\Filament; use Filament\Forms; use Filament\Forms\Components\DateTimePicker; use Filament\Forms\Components\Radio; +use Filament\Forms\Components\Section; use Filament\Forms\Components\Select; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; @@ -33,7 +34,7 @@ class MotorTestingMasterResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; - protected static ?string $navigationGroup = 'Testing Panel'; + protected static ?string $navigationGroup = 'Motor Testing Panel'; protected static ?int $navigationSort = 1; @@ -41,387 +42,429 @@ class MotorTestingMasterResource extends Resource { return $form ->schema([ - Forms\Components\Select::make('plant_id') - ->label('Plant Name') - ->relationship('plant', 'name') - ->required() - ->searchable() - ->reactive() - ->options(function (callable $get) { - $userHas = Filament::auth()->user()->plant_id; + Section::make('') + ->schema([ + Forms\Components\Select::make('plant_id') + ->label('Plant Name') + ->relationship('plant', 'name') + ->columnSpan(1) // (['default' => 1, 'sm' => 2]) + ->required() + ->searchable() + ->reactive() + ->options(function (callable $get) { + $userHas = Filament::auth()->user()->plant_id; - return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); - }) - ->default(function () { - return optional(MotorTestingMaster::latest()->first())->plant_id; - }) - ->disabled(fn (Get $get) => ! empty($get('id'))) - ->afterStateUpdated(function ($state, callable $set, callable $get) { - $plantId = $get('plant_id'); - if (! $plantId) { - $set('mTmError', 'Please select a plant first.'); + return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray(); + }) + ->default(function () { + $userHas = Filament::auth()->user()->plant_id; - return; - } else { - $set('mTmError', null); - } + return ($userHas && strlen($userHas) > 0) ? $userHas : optional(MotorTestingMaster::latest()->first())->plant_id ?? null; + }) + ->disabled(fn (Get $get) => ! empty($get('id'))) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $plantId = $get('plant_id'); + if (! $plantId) { + $set('mTmError', 'Please select a plant first.'); + + return; + } else { + $set('mTmError', null); + } + + $set('updated_by', Filament::auth()->user()?->name); + }) + ->extraAttributes(fn ($get) => [ + 'class' => $get('mTmError') ? 'border-red-500' : '', + ]) + ->hint(fn ($get) => $get('mTmError') ? $get('mTmError') : null) + ->hintColor('danger'), + Forms\Components\TimePicker::make('routine_test_time') + ->label('Routine Test Time') + ->default('00:40:00') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->reactive(), + Forms\Components\Select::make('item_id') + ->label('Item Code') + // ->relationship('item', 'name') + ->options(function (callable $get) { + $plantId = $get('plant_id'); + if (! $plantId) { + return []; + } + + if (! $get('id')) { + // whereHas + return Item::where('plant_id', $plantId)->whereDoesntHave('motorTestingMasters')->pluck('code', 'id'); + } else { + $itemId = MotorTestingMaster::where('id', $get('id'))->first()?->item_id; + + return Item::where('plant_id', $plantId) + ->where(function ($query) use ($itemId) { + $query->whereDoesntHave('motorTestingMasters') + ->orWhere('id', $itemId); + }) + ->pluck('code', 'id'); + } + // return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray(); + }) + ->columnSpan(1) + ->required() + ->searchable() + ->reactive() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->rule(function (callable $get) { + return Rule::unique('motor_testing_masters', 'item_id') + ->where('plant_id', $get('plant_id')) + ->ignore($get('id')); // Ignore current record during updates + }), + Forms\Components\TextInput::make('subassembly_code') + ->label('Subassembly Code') + // ->required() + ->placeholder('Scan the subassembly code') + ->columnSpan(1) + ->reactive() + ->alphaNum() + ->minLength(6) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $code = $get('subassembly_code'); + if (! $code) { + $set('iCodeError', 'Scan the valid Subassembly Code.'); + + return; + } else { + if (strlen($code) < 6) { + $set('iCodeError', 'Subassembly code must be at least 6 digits.'); + + return; + } elseif (! preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) { + $set('code', null); + $set('iCodeError', 'Subassembly code must contain only alpha-numeric characters.'); + + return; + } + $set('iCodeError', null); + } + + $set('updated_by', Filament::auth()->user()?->name); + }) + ->extraAttributes(fn ($get) => [ + 'class' => $get('iCodeError') ? 'border-red-500' : '', + ]) + ->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null) + ->hintColor('danger'), + + Forms\Components\Select::make('isi_model') + ->label('ISI Model') + ->options([ + 1 => 'Yes', + 0 => 'No', + ]) + ->selectablePlaceholder(false) + ->default(1) + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->reactive(), + Forms\Components\Select::make('phase') + ->label('Phase') + ->options(function (callable $get) { + $plantId = $get('plant_id'); + + if ($plantId) { + return Configuration::where('plant_id', $plantId) + ->where('c_name', 'MOTOR_PHASE') + ->orderBy('created_at') + ->pluck('c_value', 'c_value') + ->toArray(); + } else { + return Configuration::where('c_name', 'MOTOR_PHASE') + ->orderBy('created_at') + ->pluck('c_value', 'c_value') + ->toArray(); + } + }) + ->selectablePlaceholder(false) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + if ($state == 'Single' && $get('connection') == 'Star-Delta') { + $set('phase', 'Three'); + } + + $set('updated_by', Filament::auth()->user()?->name); + }) + ->default('Single') + ->columnSpan(1) + ->required() + ->reactive(), + Forms\Components\TextInput::make('hp') + ->label('HP') + ->placeholder('Scan the HP') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('kw') + ->label('KW') + ->placeholder('Scan the KW') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('volt') + ->label('Volt') + ->placeholder('Scan the volt') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('current') + ->label('Current') + ->placeholder('Scan the current') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('rpm') + ->label('RPM') + ->placeholder('Scan the RPM') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('torque') + ->label('Torque') + ->placeholder('Scan the torque') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('frequency') + ->label('Frequency') + ->placeholder('Scan the frequency') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\Select::make('connection') + ->label('Connection') + ->selectablePlaceholder(false) + ->options(function (callable $get) { + $plantId = $get('plant_id'); + if ($plantId) { + return Configuration::where('plant_id', $plantId) + ->where('c_name', 'MOTOR_CONNECTION') + ->orderBy('created_at') + ->pluck('c_value', 'c_value') + ->toArray(); + } else { + return Configuration::where('c_name', 'MOTOR_CONNECTION') + ->orderBy('created_at') + ->pluck('c_value', 'c_value') + ->toArray(); + } + }) + ->afterStateUpdated(function ($state, callable $set) { + if ($state == 'Star-Delta') { + $set('phase', 'Three'); + } + + $set('updated_by', Filament::auth()->user()?->name); + }) + ->columnSpan(1) + ->required() + ->default('Star') + ->reactive(), + Forms\Components\TextInput::make('ins_res_limit') + ->label('Insulation Resistance Limit') + ->placeholder('Scan the insulation resistance limit') + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }) + ->columnSpan(1) + ->required(), + Forms\Components\Select::make('ins_res_type') + ->label('Insulation Resistance Type') + ->placeholder('Scan the insulation resistance type') + ->columnSpan(1) + ->default('O') + ->selectablePlaceholder(false) + ->options(function (callable $get) { + $plantId = $get('plant_id'); + if ($plantId) { + return Configuration::where('plant_id', $plantId) + ->where('c_name', 'INSULATION_RESISTANCE_TYPE') + ->orderBy('created_at') + ->pluck('c_value', 'c_value') + ->toArray(); + } else { + return Configuration::where('c_name', 'INSULATION_RESISTANCE_TYPE') + ->orderBy('created_at') + ->pluck('c_value', 'c_value') + ->toArray(); + } + }) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('res_ry_ll') + ->label('Resistance RY LL') + ->placeholder('Scan the resistance RY LL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('res_ry_ul') + ->label('Resistance RY UL') + ->placeholder('Scan the resistance RY UL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('res_yb_ll') + ->label('Resistance YB LL') + ->placeholder('Scan the resistance YB LL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('res_yb_ul') + ->label('Resistance YB UL') + ->placeholder('Scan the resistance YB UL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('res_br_ll') + ->label('Resistance BR LL') + ->placeholder('Scan the resistance BR LL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('res_br_ul') + ->label('Resistance BR UL') + ->placeholder('Scan the resistance BR UL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('lock_volt_limit') + ->label('Lock Volt Limit') + ->placeholder('Scan the lock volt limit') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('leak_cur_limit') + ->label('Leakage Current Limit') + ->placeholder('Scan the leakage current limit') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('lock_cur_ll') + ->label('Lock Current LL') + ->placeholder('Scan the lock current LL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('lock_cur_ul') + ->label('Lock Current UL') + ->placeholder('Scan the lock current UL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('noload_cur_ll') + ->label('No Load Current LL') + ->placeholder('Scan the no load current LL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('noload_cur_ul') + ->label('No Load Current UL') + ->placeholder('Scan the no load current UL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('noload_pow_ll') + ->label('No Load Power LL') + ->placeholder('Scan the no load power LL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('noload_pow_ul') + ->label('No Load Power UL') + ->placeholder('Scan the no load power UL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('noload_spd_ll') + ->label('No Load Speed LL') + ->placeholder('Scan the no load speed LL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\TextInput::make('noload_spd_ul') + ->label('No Load Speed UL') + ->placeholder('Scan the no load speed UL') + ->columnSpan(1) + ->required() + ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { + $set('updated_by', Filament::auth()->user()?->name); + }), + Forms\Components\Hidden::make('created_by') + ->default(fn () => Filament::auth()->user()?->name) + ->columnSpan(1) + ->required(), + Forms\Components\Hidden::make('updated_by') + ->default(fn () => Filament::auth()->user()?->name) + ->columnSpan(1) + ->required(), + Forms\Components\TextInput::make('id') + ->hidden() + ->columnSpan(1) + ->readOnly(), - $set('updated_by', Filament::auth()->user()?->name); - }) - ->extraAttributes(fn ($get) => [ - 'class' => $get('mTmError') ? 'border-red-500' : '', ]) - ->hint(fn ($get) => $get('mTmError') ? $get('mTmError') : null) - ->hintColor('danger'), - Forms\Components\TimePicker::make('routine_test_time') - ->label('Routine Test Time') - ->default('00:40:00') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }) - ->reactive(), - Forms\Components\Select::make('item_id') - ->label('Item Code') - // ->relationship('item', 'name') - ->options(function (callable $get) { - $plantId = $get('plant_id'); - if (! $plantId) { - return []; - } - - if (! $get('id')) { - // whereHas - return Item::where('plant_id', $plantId)->whereDoesntHave('motorTestingMasters')->pluck('code', 'id'); - } else { - $itemId = MotorTestingMaster::where('id', $get('id'))->first()?->item_id; - - return Item::where('plant_id', $plantId) - ->where(function ($query) use ($itemId) { - $query->whereDoesntHave('motorTestingMasters') - ->orWhere('id', $itemId); - }) - ->pluck('code', 'id'); - } - // return Item::where('plant_id', $plantId)->pluck('code', 'id')->toArray(); - }) - ->required() - ->searchable() - ->reactive() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }) - ->rule(function (callable $get) { - return Rule::unique('motor_testing_masters', 'item_id') - ->where('plant_id', $get('plant_id')) - ->ignore($get('id')); // Ignore current record during updates - }), - Forms\Components\TextInput::make('subassembly_code') - ->label('Subassembly Code') - // ->required() - ->placeholder('Scan the subassembly code') - ->reactive() - ->alphaNum() - ->minLength(6) - ->afterStateUpdated(function ($state, callable $set, callable $get) { - $code = $get('subassembly_code'); - if (! $code) { - $set('iCodeError', 'Scan the valid Subassembly Code.'); - - return; - } else { - if (strlen($code) < 6) { - $set('iCodeError', 'Subassembly code must be at least 6 digits.'); - - return; - } elseif (! preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) { - $set('code', null); - $set('iCodeError', 'Subassembly code must contain only alpha-numeric characters.'); - - return; - } - $set('iCodeError', null); - } - - $set('updated_by', Filament::auth()->user()?->name); - }) - ->extraAttributes(fn ($get) => [ - 'class' => $get('iCodeError') ? 'border-red-500' : '', - ]) - ->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null) - ->hintColor('danger'), - - Forms\Components\Select::make('isi_model') - ->label('ISI Model') - ->options([ - 1 => 'Yes', - 0 => 'No', - ]) - ->selectablePlaceholder(false) - ->default(1) - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }) - ->reactive(), - Forms\Components\Select::make('phase') - ->label('Phase') - ->options(function (callable $get) { - $plantId = $get('plant_id'); - - if ($plantId) { - return Configuration::where('plant_id', $plantId) - ->where('c_name', 'MOTOR_PHASE') - ->orderBy('created_at') - ->pluck('c_value', 'c_value') - ->toArray(); - } else { - return Configuration::where('c_name', 'MOTOR_PHASE') - ->orderBy('created_at') - ->pluck('c_value', 'c_value') - ->toArray(); - } - }) - ->selectablePlaceholder(false) - ->afterStateUpdated(function ($state, callable $set, callable $get) { - if ($state == 'Single' && $get('connection') == 'Star-Delta') { - $set('phase', 'Three'); - } - - $set('updated_by', Filament::auth()->user()?->name); - }) - ->default('Single') - ->required() - ->reactive(), - Forms\Components\TextInput::make('hp') - ->label('HP') - ->placeholder('Scan the HP') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('kw') - ->label('KW') - ->placeholder('Scan the KW') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('volt') - ->label('Volt') - ->placeholder('Scan the volt') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('current') - ->label('Current') - ->placeholder('Scan the current') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('rpm') - ->label('RPM') - ->placeholder('Scan the RPM') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('torque') - ->label('Torque') - ->placeholder('Scan the torque') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('frequency') - ->label('Frequency') - ->placeholder('Scan the frequency') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\Select::make('connection') - ->label('Connection') - ->selectablePlaceholder(false) - ->options(function (callable $get) { - $plantId = $get('plant_id'); - if ($plantId) { - return Configuration::where('plant_id', $plantId) - ->where('c_name', 'MOTOR_CONNECTION') - ->orderBy('created_at') - ->pluck('c_value', 'c_value') - ->toArray(); - } else { - return Configuration::where('c_name', 'MOTOR_CONNECTION') - ->orderBy('created_at') - ->pluck('c_value', 'c_value') - ->toArray(); - } - }) - ->afterStateUpdated(function ($state, callable $set) { - if ($state == 'Star-Delta') { - $set('phase', 'Three'); - } - - $set('updated_by', Filament::auth()->user()?->name); - }) - ->required() - ->default('Star') - ->reactive(), - Forms\Components\TextInput::make('ins_res_limit') - ->label('Insulation Resistance Limit') - ->placeholder('Scan the insulation resistance limit') - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }) - ->required(), - Forms\Components\Select::make('ins_res_type') - ->label('Insulation Resistance Type') - ->placeholder('Scan the insulation resistance type') - ->default('O') - ->selectablePlaceholder(false) - ->options(function (callable $get) { - $plantId = $get('plant_id'); - if ($plantId) { - return Configuration::where('plant_id', $plantId) - ->where('c_name', 'INSULATION_RESISTANCE_TYPE') - ->orderBy('created_at') - ->pluck('c_value', 'c_value') - ->toArray(); - } else { - return Configuration::where('c_name', 'INSULATION_RESISTANCE_TYPE') - ->orderBy('created_at') - ->pluck('c_value', 'c_value') - ->toArray(); - } - }) - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('res_ry_ll') - ->label('Resistance RY LL') - ->placeholder('Scan the resistance RY LL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('res_ry_ul') - ->label('Resistance RY UL') - ->placeholder('Scan the resistance RY UL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('res_yb_ll') - ->label('Resistance YB LL') - ->placeholder('Scan the resistance YB LL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('res_yb_ul') - ->label('Resistance YB UL') - ->placeholder('Scan the resistance YB UL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('res_br_ll') - ->label('Resistance BR LL') - ->placeholder('Scan the resistance BR LL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('res_br_ul') - ->label('Resistance BR UL') - ->placeholder('Scan the resistance BR UL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('lock_volt_limit') - ->label('Lock Volt Limit') - ->placeholder('Scan the lock volt limit') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('leak_cur_limit') - ->label('Leakage Current Limit') - ->placeholder('Scan the leakage current limit') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('lock_cur_ll') - ->label('Lock Current LL') - ->placeholder('Scan the lock current LL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('lock_cur_ul') - ->label('Lock Current UL') - ->placeholder('Scan the lock current UL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('noload_cur_ll') - ->label('No Load Current LL') - ->placeholder('Scan the no load current LL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('noload_cur_ul') - ->label('No Load Current UL') - ->placeholder('Scan the no load current UL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('noload_pow_ll') - ->label('No Load Power LL') - ->placeholder('Scan the no load power LL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('noload_pow_ul') - ->label('No Load Power UL') - ->placeholder('Scan the no load power UL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('noload_spd_ll') - ->label('No Load Speed LL') - ->placeholder('Scan the no load speed LL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\TextInput::make('noload_spd_ul') - ->label('No Load Speed UL') - ->placeholder('Scan the no load speed UL') - ->required() - ->afterStateUpdated(function (callable $set, callable $get, ?string $state) { - $set('updated_by', Filament::auth()->user()?->name); - }), - Forms\Components\Hidden::make('created_by') - ->default(fn () => Filament::auth()->user()?->name) - ->required(), - Forms\Components\Hidden::make('updated_by') - ->default(fn () => Filament::auth()->user()?->name) - ->required(), - Forms\Components\TextInput::make('id') - ->hidden() - ->readOnly(), + ->columns(['default' => 1, 'sm' => 2]), ]); } @@ -577,6 +620,7 @@ class MotorTestingMasterResource extends Resource ->alignCenter() ->sortable(), Tables\Columns\TextColumn::make('deleted_at') + ->label('Deleted At') ->dateTime() ->alignCenter() ->sortable()