Hello, I have this resource in web.php
Route::resource('chalkboard', 'ChalkboardController');
and in my blade template:
href="{{ route('chalkboard.index') }}"
which works fine, but if I try and use dot notation to add a slash:
Route::resource('chalk.board', 'ChalkboardController');
href="{{ route('chalk.board.index') }}"
then I get the error:
Missing required parameters for [Route: chalk.board.index] [URI: chalk/{chalk}/board]
what am I doing wrong?
Ta! RT
The . suspect that it are 2 nested resources. (See php artisan route:list )
If you use the / Route::resource('chalk/board', 'ChalkboardController');
You will see that you have a chalk/board url with the name board.index.
If you want to have the chalk.board.index as name as well the other names you have multiple options:
1: use the names function:
Route::resource('chalk/board', 'ChalkboardController')->names([
'index' => 'chalk.board.index',
'store' => 'chalk.board.store',
// and the create, update, show, destroy and edit
]);
2: Use the name function for each route:
Route::resource('chalk/board', 'ChalkboardController')
->name('index', 'chalk.board.index')
->name('store', 'chalk.board.store')
// and the create, update, show, destroy and edit
;
3: Put it in a group with a name:
Route::name('chalk.')->group(function () {
Route::resource('chalk/board', 'ChalkboardController');
});
I couldn't find any similar nested routes so it could be a bug? I'm going to go with the route names anyway, I didn't know re-naming resources was so easy, thanks!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community