Get Model id on Widget
hi all, i've this widget:
but how i can find the id of casting here
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)
]),
]);
}
}
Message::query()->where('casting_id', 22)
?0 Replies