add action on infolist/view on relation manager?

Hello, I have a relation manager between "customers" and "events". So, on my customer resources pages I can see all their events. When I click on one, I open an infolist. Is there a way to add a button on the infolist when we're on a relation manager ? I can't find anything about that Thx!
Solution:
I think you can just add the Infolist Actions component so in you RelationManager class: ```...
Jump to solution
2 Replies
Solution
Marco
Marco4mo ago
I think you can just add the Infolist Actions component so in you RelationManager class:
public function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
TextEntry::make('id'),
Actions::make([
Actions\Action::make('custom_action')
->action(fn () => dd('Custom action'))
]),
]);
}
public function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
TextEntry::make('id'),
Actions::make([
Actions\Action::make('custom_action')
->action(fn () => dd('Custom action'))
]),
]);
}
Jérôme
JérômeOP4mo ago
oh really? Let me try Yeah you're right @Marco It's working great Thx a lot!
return $infolist
->schema([
Actions::make([
Action::make('markAsRead')
->label('Marquer comme lu')
->icon('heroicon-s-document')
->hidden(fn (Event $event): bool => !$event->is_new)
->action(function (Event $event) {
$event->is_new = false;
$event->save();
}),

Action::make('maskAsUnread')
->label('Marquer comme non lu')
->icon('heroicon-o-document')
->hidden(fn (Event $event): bool => $event->is_new)
->action(function (Event $event) {
$event->is_new = true;
$event->save();
}),
]),
Group::make()
->schema([
...
])->columnSpanFull(),
]);
}
return $infolist
->schema([
Actions::make([
Action::make('markAsRead')
->label('Marquer comme lu')
->icon('heroicon-s-document')
->hidden(fn (Event $event): bool => !$event->is_new)
->action(function (Event $event) {
$event->is_new = false;
$event->save();
}),

Action::make('maskAsUnread')
->label('Marquer comme non lu')
->icon('heroicon-o-document')
->hidden(fn (Event $event): bool => $event->is_new)
->action(function (Event $event) {
$event->is_new = true;
$event->save();
}),
]),
Group::make()
->schema([
...
])->columnSpanFull(),
]);
}
Want results from more Discord servers?
Add your server