schema([ Forms\Components\TextInput::make('sticker_id') ->label('Sticker ID') ->reactive() ->required() ->afterStateUpdated(function ($state, callable $set) { //\Log::info('Sticker ID typed:', ['sticker_id' => $state]); $set('sticker_id_live', $state); }), Forms\Components\TextInput::make('sticker_width') ->label('Sticker Width') ->required(), Forms\Components\TextInput::make('sticker_height') ->label('Sticker Height') ->required(), Forms\Components\TextInput::make('sticker_lmargin') ->label('Sticker Left Margin') ->required(), Forms\Components\TextInput::make('sticker_rmargin') ->label('Sticker Right Margin') ->required(), Forms\Components\TextInput::make('sticker_tmargin') ->label('Sticker Top Margin') ->required(), Forms\Components\TextInput::make('sticker_bmargin') ->label('Sticker Bottom Margin') ->required(), Forms\Components\Hidden::make('created_by') ->label('Created By') ->default(Filament::auth()->user()?->name), Forms\Components\Hidden::make('updated_by') ->label('Updated By') ->default(Filament::auth()->user()?->name), Forms\Components\TextInput::make('sticker_id_live') ->default(fn ($get) => $get('sticker_id')) ->reactive() ->afterStateUpdated(function ($state, callable $set) { \Log::info('Sticker ID Live:', ['sticker_id_live' => $state]); $set('sticker_id_live', $state); }), Forms\Components\ViewField::make('generate_template') ->view('fields.generate-template') ->reactive() ->key(fn ($get) => 'generate-template' . ($get('sticker_id_live') ?? 'empty')) ->viewData(fn (Get $get) => [ 'sticker_id' => $get('sticker_id_live') ?? 'empty', ]) // ->extraAttributes([ // // Pass the current sticker_id typed by the user // //'sticker_id' => fn ($get) => $get('sticker_id'), // 'sticker_id' => fn ($get) => $get('sticker_id') ?? 'empty', // // 'sticker_id' => function ($get) { // // \Log::info('ViewField closure executed'); // // $stickerId = $get('sticker_id'); // // // Use Laravel log to see value in real time // // \Log::info('Sticker ID in ViewField:', $stickerId); // // // You can also temporarily dd(), but it will stop form render // // // dd($stickerId); // // return $stickerId; // // }, // ]), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('id') ->label('ID') ->numeric() ->sortable(), Tables\Columns\TextColumn::make('sticker_id') ->label('Sticker ID'), Tables\Columns\TextColumn::make('sticker_width') ->label('Sticker Width'), Tables\Columns\TextColumn::make('sticker_height') ->label('Sticker Height'), Tables\Columns\TextColumn::make('sticker_lmargin') ->label('Sticker Left Margin'), Tables\Columns\TextColumn::make('sticker_rmargin') ->label('Sticker Right Margin'), Tables\Columns\TextColumn::make('sticker_tmargin') ->label('Sticker Top Margin'), Tables\Columns\TextColumn::make('sticker_bmargin') ->label('Sticker Bottom Margin'), Tables\Columns\TextColumn::make('created_at') ->label('Created At') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('updated_at') ->label('Updated At') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('deleted_at') ->label('Deleted At') ->dateTime() ->sortable() ->toggleable(isToggledHiddenByDefault: true), ]) ->filters([ Tables\Filters\TrashedFilter::make(), ]) ->actions([ Tables\Actions\ViewAction::make(), Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), Tables\Actions\ForceDeleteBulkAction::make(), Tables\Actions\RestoreBulkAction::make(), ]), ]) ->headerActions([ ImportAction::make() ->label('Import Sticker Structure Details') ->color('warning') ->importer(StickerStructureDetailImporter::class) ->visible(function() { return Filament::auth()->user()->can('view import sticker structure details'); }), ExportAction::make() ->label('Export Sticker Structure Details') ->color('warning') ->exporter(StickerStructureDetailExporter::class) ->visible(function() { return Filament::auth()->user()->can('view export sticker structure details'); }), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListStickerStructureDetails::route('/'), 'create' => Pages\CreateStickerStructureDetail::route('/create'), 'view' => Pages\ViewStickerStructureDetail::route('/{record}'), 'edit' => Pages\EditStickerStructureDetail::route('/{record}/edit'), ]; } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() ->withoutGlobalScopes([ SoftDeletingScope::class, ]); } }