Getting Url of Resource View Page

Hello, I think this really a stupid question but is one hour that I'm hitting my head over it and I did not find any solution in the docs. I want a table ViewAction to redirect to the view page of the rosurce but, hoe do i get the route of the page? I'have tried everything but I keep getting errors
12 Replies
Dan Harrin
Dan Harrin2y ago
ResourceName::getUrl('view', ['record' => $record]) but ViewAction should redirect to the view page anyway... you shouldnt need to generate the url
Gianmarco Varrone
Can i call this in the url method of the action?
Dan Harrin
Dan Harrin2y ago
why? it should do it automatically what happens when you click on the ViewAction
Gianmarco Varrone
Let me explain, I created a custom page "Help Center" where the users must be able to have an overview of open tickets, charts, stats etc. I want them, when they click on the view action of the table to be redirected to the view page of the ticket but at the moment it's only opening an empty modal
Dan Harrin
Dan Harrin2y ago
show me the resource's routes() and table() code
Gianmarco Varrone
protected function getTableColumns(): array { return[ Split::make([ BadgeColumn::make('priority')->label('Priorità')->color(static function ($state): string { if ($state == "low") { return 'success'; }elseif($state == "normal"){ return 'blue'; }elseif($state == "high"){ return 'warning'; }elseif($state == "critical"){ return "danger"; } })->enum([ "low" => "Bassa", "normal"=>"Normale", "high"=> "Alta", "critical"=> "Critica", ]), TextColumn::make('created_at')->date(), BadgeColumn::make('status')->label('Status')->color(static function ($state): string { if ($state == "open") { return 'blue'; }elseif($state == "pending"){ return 'warning'; }elseif($state == "resolved"){ return 'blue'; }elseif($state == "closed"){ return 'success'; } })->enum([ "open" => "Aperto", "pending"=>"In attesa", "resolved"=> "Risolto", "closed"=>"Chiuso", ]), ]), ViewColumn::make('request')->view('tables.columns.bookings.ticket-detail'), Panel::make([ Stack::make([ ViewColumn::make('notes')->view('tables.columns.bookings.ticket-updates'), ]), ])->collapsible(), ]; The following are the resources. routes public static function getPages(): array { return [ 'index' => Pages\ListTickets::route('/'), 'create' => Pages\CreateTicket::route('/create'), 'view' => Pages\ViewTicket::route('/{record}'), 'edit' => Pages\EditTicket::route('/{record}/edit'), ]; }
Dan Harrin
Dan Harrin2y ago
i thought you said this was a resource why are you using getTableColumns()
Gianmarco Varrone
Because as said above this a custom page that i called help center
Dan Harrin
Dan Harrin2y ago
okay so ->url(fn ($record) => TicketResource::getUrl('view', ['record' => $record]))
Gianmarco Varrone
Yes, It's working. Thanks so much. As I'm here, may i know how to get the avatar of the user using ui-avatar in filament?
Dan Harrin
Dan Harrin2y ago
Filament::getUserAvatarUrl($user) i think something like that
Gianmarco Varrone
Ok, I'll try. Thank you so much
Want results from more Discord servers?
Add your server