diff --git a/app/Filament/Resources/MotorTestingMasterResource.php b/app/Filament/Resources/MotorTestingMasterResource.php index 8c4521b..2b6b0c1 100644 --- a/app/Filament/Resources/MotorTestingMasterResource.php +++ b/app/Filament/Resources/MotorTestingMasterResource.php @@ -119,7 +119,7 @@ class MotorTestingMasterResource extends Resource Forms\Components\TextInput::make('subassembly_code') ->label('Subassembly Code') // ->required() - ->placeholder('Scan the valid code') + ->placeholder('Scan the subassembly code') ->reactive() ->alphaNum() ->minLength(6) @@ -195,42 +195,49 @@ class MotorTestingMasterResource extends Resource ->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); @@ -265,12 +272,14 @@ class MotorTestingMasterResource extends Resource ->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) { @@ -294,96 +303,112 @@ class MotorTestingMasterResource extends Resource }), 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); @@ -420,6 +445,7 @@ class MotorTestingMasterResource extends Resource ->sortable(), Tables\Columns\TextColumn::make('item.category') ->label('Category') + ->default('-') ->searchable() ->alignCenter() ->sortable(), @@ -430,6 +456,7 @@ class MotorTestingMasterResource extends Resource ->sortable(), Tables\Columns\TextColumn::make('subassembly_code') ->label('Subassembly Code') + ->default('-') ->searchable() ->alignCenter() ->sortable(), @@ -593,17 +620,34 @@ class MotorTestingMasterResource extends Resource ->options(function (callable $get) { $pId = $get('Plant'); - return Item::whereHas('motorTestingMasters', function ($query) use ($pId) { - if ($pId) { - $query->where('plant_id', $pId); - } - })->pluck('code', 'id'); + if (! $pId) { + return []; + } else { + return Item::whereHas('motorTestingMasters', function ($query) use ($pId) { + if ($pId) { + $query->where('plant_id', $pId); + } + })->pluck('code', 'id'); + } + }) + ->searchable() + ->reactive(), + Select::make('subassembly_code') + ->label('Search by Subassembly Code') + ->nullable() + ->options(function (callable $get) { + $plantId = $get('Plant'); + if (! $plantId) { + return []; + } else { + return MotorTestingMaster::where('plant_id', $plantId)->whereNotNull('subassembly_code')->select('subassembly_code')->distinct()->pluck('subassembly_code', 'subassembly_code'); + } }) ->searchable() ->reactive(), TextInput::make('description') - ->label('Description') - ->placeholder('Enter Description'), + ->label('Model') + ->placeholder('Enter Model'), Radio::make('isi_type') ->label('ISI Model ?') ->boolean() @@ -714,7 +758,7 @@ class MotorTestingMasterResource extends Resource ]) ->query(function ($query, array $data) { // Hide all records initially if no filters are applied - if (empty($data['Plant']) && empty($data['Item']) && empty($data['description']) && empty($data['isi_type']) && empty($data['phase_type']) && empty($data['connection_type']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {// || $data['isi_type'] == 'All') + if (empty($data['Plant']) && empty($data['Item']) && empty($data['subassembly_code']) && empty($data['description']) && empty($data['isi_type']) && empty($data['phase_type']) && empty($data['connection_type']) && empty($data['created_by']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['updated_by']) && empty($data['updated_from']) && empty($data['updated_to'])) {// || $data['isi_type'] == 'All') return $query->whereRaw('1 = 0'); } @@ -738,6 +782,10 @@ class MotorTestingMasterResource extends Resource } } + if (! empty($data['subassembly_code'])) { + $query->where('subassembly_code', $data['subassembly_code']); + } + if (! empty($data['description'])) { $pId = $data['Plant'] ?? null; $descIds = Item::where('description', 'like', '%'.$data['description'].'%')->whereHas('motorTestingMasters', function ($query) use ($pId) { @@ -807,8 +855,12 @@ class MotorTestingMasterResource extends Resource $indicators[] = 'Item Codes: '.$itemCode; } + if (! empty($data['subassembly_code'])) { + $indicators[] = 'Subassembly Code: '.$data['subassembly_code']; + } + if (! empty($data['description'])) { - $indicators[] = 'Description: '.$data['description']; + $indicators[] = 'Model: '.$data['description']; } if ($data['isi_type'] == 'Y') {