Updated load available model_type only on resource page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 22s
Laravel Larastan / larastan (pull_request) Failing after 6m35s
Laravel Pint / pint (pull_request) Failing after 14m47s

This commit is contained in:
dhanabalan
2026-09-07 12:58:55 +05:30
parent 39a6e084d2
commit 66955e402c

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'])) {