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
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:
@@ -437,17 +437,27 @@ class RequestCharacteristicResource extends Resource
|
|||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||||
Forms\Components\TextInput::make('model_type')
|
Forms\Components\Select::make('model_type')
|
||||||
->label('Model Type')
|
->label('Model Type')
|
||||||
->reactive()
|
->reactive()
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->required()
|
||||||
|
->options(function () {
|
||||||
|
return [
|
||||||
|
'MOTOR' => 'MOTOR',
|
||||||
|
'PUMP' => 'PUMP',
|
||||||
|
'NAME_PLATE' => 'NAME_PLATE',
|
||||||
|
'UNKNOWN' => 'UNKNOWN',
|
||||||
|
];
|
||||||
|
})
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('characteristic_name', null);
|
$set('characteristic_name', null);
|
||||||
$set('current_value', null);
|
$set('current_value', null);
|
||||||
$set('update_value', null);
|
$set('update_value', null);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required()
|
->default('MOTOR')
|
||||||
->disabled(fn (Get $get) => ! empty($get('id'))),
|
->disabled(fn (Get $get) => ! empty($get('id'))),
|
||||||
Section::make('Request Characteristic Details')
|
Section::make('Request Characteristic Details')
|
||||||
// ->columnSpan(['default' => 2, 'sm' => 4])
|
// ->columnSpan(['default' => 2, 'sm' => 4])
|
||||||
@@ -1308,9 +1318,23 @@ class RequestCharacteristicResource extends Resource
|
|||||||
TextInput::make('master_characteristic_field')
|
TextInput::make('master_characteristic_field')
|
||||||
->label('Master Characteristic Field')
|
->label('Master Characteristic Field')
|
||||||
->placeholder('Enter Master Characteristic Field'),
|
->placeholder('Enter Master Characteristic Field'),
|
||||||
TextInput::make('model_type')
|
Select::make('model_type')
|
||||||
->label('Model Type')
|
->label('Search by Model Type')
|
||||||
->placeholder('Enter 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')
|
Select::make('approver_status')
|
||||||
->label('Approver Status')
|
->label('Approver Status')
|
||||||
->options([
|
->options([
|
||||||
@@ -1397,7 +1421,7 @@ class RequestCharacteristicResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['model_type'])) {
|
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'])) {
|
if (! empty($data['work_flow_id'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user