1
votes

The documentation says:

If the named route defines parameters, you may pass the parameters as the second argument to the route function. The given parameters will automatically be inserted into the URL in their correct positions:

Route::get('user/{id}/profile', ['as' => 'profile', function ($id) {
    //
}]);

$url = route('profile', ['id' => 1]);

If i do have a nested resource route by using Route::resource(...) twice, i will get a named route wich contains a placeholder like

employees.{employee}.images.index

How can i create a route for this nested resource using the blade templating engine?

I thought about

route('employees.{employee}.images.index', ['employee' => $employee->id]);

but that does not work. I know i can "manually" create the routes, but this will make them less maintainable.

Update 1 I know i can name the routes manually and then use the given name. But if there is a way without naming them i would prefer it.

1

1 Answers

2
votes

You don't have to add anything like employee into a route name. Run php artisan route:list command and you will see real names of all routes (look at column called Name), created by resource clause. Then just use them like usual:

route('employees.images.index', ['employee' => $employee->id]);

Also, you can name resource routes.