diff --git a/app/Filament/Resources/StickerMasterResource.php b/app/Filament/Resources/StickerMasterResource.php index 23ccffc..1adad80 100644 --- a/app/Filament/Resources/StickerMasterResource.php +++ b/app/Filament/Resources/StickerMasterResource.php @@ -18,6 +18,7 @@ use Filament\Tables\Table; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; use Filament\Forms\Get; +use Filament\Forms\Set; use Filament\Tables\Actions\ExportAction; use Filament\Tables\Actions\ImportAction; // use Illuminate\Validation\Rule; @@ -153,12 +154,26 @@ class StickerMasterResource extends Resource ->hint(fn ($get) => $get('item_error') ? $get('item_error') : null) ->hintColor('danger'), - Forms\Components\TextInput::make('item_description') - ->label('Description') - ->required() - ->reactive() - ->readOnly(true), + ->label('Description') + ->required() + ->afterStateHydrated(function ($component, $state, Get $get, Set $set) { + if ($get('id')) { + $itemId = StickerMaster::where('id', $get('id'))->first()?->item_id; + if ($itemId) { + $item = \App\Models\Item::where('id', $itemId)->first()?->description; + if ($item) { + $set('item_description', $item); + } else { + $set('item_description', null); + } + } else { + $set('item_description', null); + } + } + }) + ->reactive() + ->readOnly(true), Forms\Components\TextInput::make('part_validation1') ->nullable(),