Entry Routers

Entry routers assist in binding named routes to stream entries. This makes it much easier to override routing by simply defining another route with the same name.

The basic idea is as that instead of something like this in your code:

{{ url('articles/' ~ category.slug ~ '/view/' ~ article.slug) }}

You can rely on entry routing to simply do this:

{{ article.route('view') }}

And via API this would look like:


Basic Usage

To get started with entry routing you must first define your routes with a specific naming pattern. Note this is not referring to the path but the route name. We'll use an AddonServiceProvider routing example:

protected $routes = [
    "posts/{slug}"                                              => [
        'as'   => 'anomaly.module.posts::posts.view',
        'uses' => 'Anomaly\PostsModule\Http\Controller\[email protected]',

Note the above route is named anomaly.module.posts::posts.view. This can be broken down into the addons namespace, then the entry's stream slug, and lastly the route action.


By calling route($action) on an entry model Pyro will lookup what addon the model belongs to and find use it's stream slug and action to return the route path.


The make method returns the entry model's matching route. The name variable can be simply an action or the stream slug and action of another named route within the same addon.

The entry's route method directly wraps make hence $entry->route($action).

Returns: string or null
Key Required Type Default Description





The route name. Can be simply action if route is for the calling model or stream.action if route is in calling model's same addon.





Query string parameters appended to the route.



// Equivalent long syntax.

{{ article.route('view') }}

{{ article.route('categories.index') }}