Merge pull request 'Updated load available model_type only on resource page' (#989) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s

Reviewed-on: #989
This commit was merged in pull request #989.
This commit is contained in:
2026-09-07 07:29:52 +00:00

View File

@@ -437,17 +437,27 @@ class RequestCharacteristicResource extends Resource
})
->required()
->disabled(fn (Get $get) => ! empty($get('id'))),
Forms\Components\TextInput::make('model_type')
Forms\Components\Select::make('model_type')
->label('Model Type')
->reactive()
->nullable()
->searchable()
->required()
->options(function () {
return [
'MOTOR' => 'MOTOR',
'PUMP' => 'PUMP',
'NAME_PLATE' => 'NAME_PLATE',
'UNKNOWN' => 'UNKNOWN',
];
})
->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('characteristic_name', null);
$set('current_value', null);
$set('update_value', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->required()
->default('MOTOR')
->disabled(fn (Get $get) => ! empty($get('id'))),
Section::make('Request Characteristic Details')
// ->columnSpan(['default' => 2, 'sm' => 4])
@@ -1308,9 +1318,23 @@ class RequestCharacteristicResource extends Resource
TextInput::make('master_characteristic_field')
->label('Master Characteristic Field')
->placeholder('Enter Master Characteristic Field'),
TextInput::make('model_type')
->label('Model Type')
->placeholder('Enter Model Type'),
Select::make('model_type')
->label('Search by Model Type')
->nullable()
->searchable()
->reactive()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
$plantId = $get('Plant');
if ($userHas && strlen($userHas) > 0) {
return RequestCharacteristic::where('plant_id', $userHas)->pluck('model_type', 'model_type')->toArray();
} elseif ($plantId) {
return RequestCharacteristic::where('plant_id', $plantId)->select('model_type')->distinct()->pluck('model_type', 'model_type');
} else {
return RequestCharacteristic::select('model_type')->distinct()->pluck('model_type', 'model_type');
}
}),
Select::make('approver_status')
->label('Approver Status')
->options([
@@ -1397,7 +1421,7 @@ class RequestCharacteristicResource extends Resource
}
if (! empty($data['model_type'])) {
$query->where('model_type', 'like', '%'.$data['model_type'].'%');
$query->where('model_type', $data['model_type']);
}
if (! empty($data['work_flow_id'])) {