Ordered zmm column in forms of item characteristics page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 20s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Laravel Larastan / larastan (pull_request) Failing after 8m25s
Laravel Pint / pint (pull_request) Successful in 19m3s

This commit is contained in:
dhanabalan
2026-11-19 11:32:23 +05:30
parent c8b0fb7d25
commit bc43e0d25e

View File

@@ -44,18 +44,28 @@ class ItemCharacteristicResource extends Resource
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->label('PLANT NAME')
->relationship('plant', 'name')
->reactive()
->searchable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->disabled(fn (Get $get) => ! empty($get('id')))
->default(function () {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(ItemCharacteristic::latest()->first())->plant_id;
})
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
$set('item_id', null);
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\Select::make('item_id')
->label('Item Code')
// ->relationship('item', 'id')
->label('ITEM CODE')
->reactive()
->searchable()
->options(function (callable $get) {
@@ -64,7 +74,19 @@ class ItemCharacteristicResource extends Resource
return [];
}
return Item::where('plant_id', $plantId)->pluck('code', 'id');
return Item::where('plant_id', $plantId)->orderBy('code')->pluck('code', 'id')->toArray();
})
->disabled(fn (Get $get) => ! empty($get('id')))
->default(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return null;
}
return ItemCharacteristic::where('plant_id', $plantId)->latest()->first()->item_id ?? null;
})
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
})
->required(),
Forms\Components\TextInput::make('class')
@@ -110,7 +132,7 @@ class ItemCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_dir_rot')
->label('ZMM DIRECTION ROTATION')
->label('ZMM DIR ROT')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
@@ -168,7 +190,8 @@ class ItemCharacteristicResource extends Resource
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
})
->required(),
Forms\Components\TextInput::make('zmm_head_max')
->label('ZMM HEAD MAX')
->reactive()
@@ -452,7 +475,7 @@ class ItemCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_eff_ovrall')
->label('ZMM OVERALL EFFICIENCY')
->label('ZMM EFF OVRALL')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
@@ -488,7 +511,7 @@ class ItemCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_ambtemp')
->label('ZMM AMBIENT TEMPERATURE')
->label('ZMM AMBTEMP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
@@ -542,7 +565,7 @@ class ItemCharacteristicResource extends Resource
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_mtrlofconst')
->label('ZMM MOTOR LOAD CONSTANT')
->label('ZMM MTRLOFCONST')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
@@ -577,6 +600,30 @@ class ItemCharacteristicResource extends Resource
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_cp')
->label('ZMM LOGO CP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_ce')
->label('ZMM LOGO CE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_nsf')
->label('ZMM LOGO NSF')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_eac')
->label('ZMM LOGO EAC')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_beenote')
->label('ZMM BEENOTE')
->reactive()
@@ -595,12 +642,6 @@ class ItemCharacteristicResource extends Resource
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_ce')
->label('ZMM LOGO CE')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_codeclass')
->label('ZMM CODECLASS')
->reactive()
@@ -613,12 +654,6 @@ class ItemCharacteristicResource extends Resource
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_cp')
->label('ZMM LOGO CP')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_grade')
->label('ZMM GRADE')
->reactive()
@@ -733,18 +768,6 @@ class ItemCharacteristicResource extends Resource
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_nsf')
->label('ZMM LOGO NSF')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_logo_eac')
->label('ZMM LOGO EAC')
->reactive()
->afterStateUpdated(function (callable $set) {
$set('updated_by', Filament::auth()->user()?->name);
}),
Forms\Components\TextInput::make('zmm_packtype')
->label('ZMM PACKTYPE')
->reactive()
@@ -877,6 +900,9 @@ class ItemCharacteristicResource extends Resource
Forms\Components\Hidden::make('updated_by')
->label('Updated By')
->default(Filament::auth()->user()?->name),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
])
->columns(3),
]);