Skip to content

How to create routes with path parameters to custom pages? #9012

Answered by elbokh
mxc asked this question in Help
Discussion options

You must be logged in to vote

Hi there!

To avoid getting the error make sure you add:

protected static bool $shouldRegisterNavigation = false;

Because it will try to load the page when it's registered in the navigation with null as the ID.

Your code should look like this:

use App\Models\Finance;


class FinancePage extends Page
{
	protected static string $view = 'filament.pages.finance';

	protected static ?string $slug = 'finance/{id}';
	protected static bool $shouldRegisterNavigation = false;
	public Finance $record; # Assuming Finance is a model.

	public function mount($id): void
	{

		$this->record = (new Finance)->FindOrFail($id);

	}
}

Hope this helps ! 😊

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mxc
Comment options

@vaishalir04
Comment options

Answer selected by mxc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants