Pass Parameters to Index Page on Panel

Hi Team. I tried to pass some extra parameters on route to index page for PanelBuilder but I have issues. Do you have any idea to solve this issue?
13 Replies
Luis Alonso
Luis Alonso11mo ago
This is for V3 Filament.
awcodes
awcodes11mo ago
You have to pass a record to it, it doesn’t read the url directly. ::route(‘/{id}, [‘id’ => $record->id] Same as using the route() helper in laravel.
AliBabba420
AliBabba4208mo ago
hey bro i have a doubt like i want to show the viewpage of a perticular record so i do this but it doesn't work
public static function getPages(): array
{
return [
'index' => Pages\ViewClinic::route('/{record}/view',['record' => auth()->id()]),
];
}
public static function getPages(): array
{
return [
'index' => Pages\ViewClinic::route('/{record}/view',['record' => auth()->id()]),
];
}
it shows [Missing parameter: record].
Dennis Koch
Dennis Koch8mo ago
auth()->user() is probably still undefined as this is processed before middlewares are run.
AliBabba420
AliBabba4208mo ago
ok if i pass like this
public static function getPages(): array
{
return [
'index' => Pages\ViewClinic::route('/{record}/view',['record' => 13
]),
];
}
public static function getPages(): array
{
return [
'index' => Pages\ViewClinic::route('/{record}/view',['record' => 13
]),
];
}
i just want to show the view page of the login user in the this resource index page only the view
Dennis Koch
Dennis Koch8mo ago
I'd create a new page and manually set the record in mount()
AliBabba420
AliBabba4208mo ago
i create a custom view page and use the mount to add the record manually this is the error
Missing required parameter for [Route: filament.clinic.resources.clinic-details.index] [URI: clinic/clinic-details/{record}/view] [Missing parameter: record].
Missing required parameter for [Route: filament.clinic.resources.clinic-details.index] [URI: clinic/clinic-details/{record}/view] [Missing parameter: record].
and
public function mount(int | string $record): void
{
$this->record = Student::where('id',2)->first();
}
public function mount(int | string $record): void
{
$this->record = Student::where('id',2)->first();
}
inside the custom view page
public static function getPages(): array
{
return [
'index' => Pages\ViewClinic::route("{record}/view"),
];
}
}
public static function getPages(): array
{
return [
'index' => Pages\ViewClinic::route("{record}/view"),
];
}
}
in the resource
Dennis Koch
Dennis Koch8mo ago
I guess you also need to overwrite the getNavigationItems() method (or similar name) so you can pass the record to the route. Otherwise Filament doesn’t know which record it needs to pass
AliBabba420
AliBabba4208mo ago
public static function getPages(): array
{
return [
'view' => Pages\Student::route('/{record}/view'),
'index' => Pages\Student::route("/profile/view"),
];
}
public static function getPages(): array
{
return [
'view' => Pages\Student::route('/{record}/view'),
'index' => Pages\Student::route("/profile/view"),
];
}
i just got one solution here like this and then in the view page a just set the record from auth()->id()
public function mount(int | string $record): void
{
$this->record = Student::where('id',auth()->id())->first();
}
public function mount(int | string $record): void
{
$this->record = Student::where('id',auth()->id())->first();
}
leoblanski
leoblanski7mo ago
Thank you so much @AliBabba420 ...
AliBabba420
AliBabba4207mo ago
Is it work for you
leoblanski
leoblanski7mo ago
yeah, perfectly, since yesterday trying to find a solution... public static function getPages(): array { return [ 'edit' => Pages\EditTeam::route('/{record}/edit'), 'index' => Pages\EditTeam::route("/settings/edit"), ]; }
AliBabba420
AliBabba4207mo ago
Mark it as a solution