Loading foreign key value while update

This commit is contained in:
dhanabalan
2025-04-01 16:16:37 +05:30
parent 6160d91357
commit a8b34fe1f3
6 changed files with 207 additions and 212 deletions

View File

@@ -32,7 +32,7 @@ class StickerMasterResource extends Resource
->relationship('plant', 'name')
->reactive()
->nullable()
->disabled(fn (Get $get) => !empty($get('id')))
->disabled(fn (Get $get) => !empty($get('id'))) //disable in edit if user try to change
->afterStateUpdated(fn (callable $set) =>
$set('item_id', null) & $set('item_description', null)
)
@@ -56,8 +56,8 @@ class StickerMasterResource extends Resource
->disabled(fn (Get $get) => !empty($get('id')))
->live(debounce: 500) // Enable live updates
->afterStateUpdated(function ($state, callable $set, callable $get) {
$plantId = $get('plant_id'); // Get selected plant_id
$itemId = $get('item_id'); // Get entered item_id
$plantId = $get('plant_id');
$itemId = $get('item_id');
// Ensure `item_id` is not cleared
if (!$plantId || !$itemId) {
@@ -77,115 +77,83 @@ class StickerMasterResource extends Resource
}
}),
// ->validationAttribute('Item Code')
// ->rule('required')
// ->extraAttributes(fn ($get) => [
// 'class' => $get('validationError') ? 'border-red-500' : '',
// ])
// ->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
// ->hintColor('danger'), // Show error in red under the input field
Forms\Components\TextInput::make('item_description')
->label('Description')
->required()
->reactive()
->readOnly(true),
//Forms\Components\Textarea::make('serial_number_motor'),
Forms\Components\TextInput::make('item_description')
->label('Description')
->required()
->reactive()
->readOnly(true),
Forms\Components\TextInput::make('part_validation1')
->nullable(),
->nullable(),
Forms\Components\TextInput::make('part_validation2')
->nullable(),
->nullable(),
Forms\Components\TextInput::make('part_validation3')
->nullable(),
->nullable(),
Forms\Components\TextInput::make('part_validation4')
->nullable(),
->nullable(),
Forms\Components\TextInput::make('part_validation5')
->nullable(),
->nullable(),
Forms\Components\Checkbox::make('serial_number_motor')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\Textarea::make('serial_number_pump')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('serial_number_pump')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('serial_number_pumpset'),
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('serial_number_pumpset')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('pack_slip_motor'),
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('pack_slip_motor')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('pack_slip_pump'),
Forms\Components\Checkbox::make('pack_slip_pump')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('pack_slip_pumpset'),
Forms\Components\Checkbox::make('pack_slip_pumpset')
Forms\Components\Checkbox::make('pack_slip_pump')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('name_plate_motor'),
Forms\Components\Checkbox::make('pack_slip_pumpset')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_motor')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_motor')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('name_plate_pump'),
Forms\Components\Checkbox::make('name_plate_pump')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pump')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('name_plate_pumpset')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('name_plate_pumpset'),
Forms\Components\Checkbox::make('name_plate_pumpset')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('tube_sticker_motor'),
Forms\Components\Checkbox::make('tube_sticker_motor')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('tube_sticker_pump'),
Forms\Components\Checkbox::make('tube_sticker_motor')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('tube_sticker_pump')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('tube_sticker_pumpset'),
Forms\Components\Checkbox::make('tube_sticker_pumpset')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null), //to pass null value
Forms\Components\Checkbox::make('tube_sticker_pumpset')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\Checkbox::make('warranty_card')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
//Forms\Components\TextInput::make('warranty_card'),
Forms\Components\Checkbox::make('warranty_card')
->nullable()
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
]);
}
@@ -196,74 +164,74 @@ class StickerMasterResource extends Resource
->searchable()
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->sortable(),
->sortable(),
Tables\Columns\TextColumn::make('plant.name')
->sortable(),
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_motor')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_pump')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('serial_number_pumpset')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_motor')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_pump')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('pack_slip_pumpset')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_motor')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_pump')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('name_plate_pumpset')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_motor')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_pump')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('tube_sticker_pumpset')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\CheckboxColumn::make('warranty_card')
->disabled(true)
->sortable(),
->disabled(true)
->sortable(),
Tables\Columns\TextColumn::make('part_validation1')
->sortable(),
->sortable(),
Tables\Columns\TextColumn::make('part_validation2')
->sortable(),
->sortable(),
Tables\Columns\TextColumn::make('part_validation3')
->sortable(),
->sortable(),
Tables\Columns\TextColumn::make('part_validation4')
->sortable(),
->sortable(),
Tables\Columns\TextColumn::make('part_validation5')
->sortable(),
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),