© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
ocram82

Get Model id on Widget

hi all, i've this widget:

class MessageWidgetTable extends BaseWidget
{
    public function table(Table $table): Table
    {
        return $table
            ->heading('')
            ->query(
                Message::query()->where('casting_id', 22)
            )
            ->columns([
                Tables\Columns\TextColumn::make('body')->label('Text')->limit(100),
                Tables\Columns\TextColumn::make('created_at')->label('Send at')->dateTime('d M Y - H:i'),
            ])
            ->actions([
                ViewAction::make()
                ->modalHeading('Text')
                ->infolist([
                    TextEntry::make('body')->markdown()->hiddenLabel(),
                    TextEntry::make('users_count')
                    ->getStateUsing(fn ($record) => $record->users->count())
                    ->label('N. Users that read at'),
                    RepeatableEntry::make('users')
                    ->label('Readers')
                    ->schema([
                        TextEntry::make('first_name')->hiddenLabel(),
                        TextEntry::make('last_name')->hiddenLabel(),
                        TextEntry::make('pivot.read_at')->date('d M Y - H:i')->hiddenLabel(),
                    ])
                    ->columns(3)
                ]),
                
                
            ]);
    }

}
class MessageWidgetTable extends BaseWidget
{
    public function table(Table $table): Table
    {
        return $table
            ->heading('')
            ->query(
                Message::query()->where('casting_id', 22)
            )
            ->columns([
                Tables\Columns\TextColumn::make('body')->label('Text')->limit(100),
                Tables\Columns\TextColumn::make('created_at')->label('Send at')->dateTime('d M Y - H:i'),
            ])
            ->actions([
                ViewAction::make()
                ->modalHeading('Text')
                ->infolist([
                    TextEntry::make('body')->markdown()->hiddenLabel(),
                    TextEntry::make('users_count')
                    ->getStateUsing(fn ($record) => $record->users->count())
                    ->label('N. Users that read at'),
                    RepeatableEntry::make('users')
                    ->label('Readers')
                    ->schema([
                        TextEntry::make('first_name')->hiddenLabel(),
                        TextEntry::make('last_name')->hiddenLabel(),
                        TextEntry::make('pivot.read_at')->date('d M Y - H:i')->hiddenLabel(),
                    ])
                    ->columns(3)
                ]),
                
                
            ]);
    }

}


but how i can find the id of casting here
Message::query()->where('casting_id', 22)
Message::query()->where('casting_id', 22)


?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Accessing Model /ResourceIn Widget
FilamentFFilament / ❓┊help
2y ago
Send Model to widget
FilamentFFilament / ❓┊help
2y ago
Model Label Based on User ID
FilamentFFilament / ❓┊help
3y ago