Reputation: 53
I create a route resource which is inside in route group. But when I call this resource route in blade template it's show me Route not defined. What should I do. I am using Laravel 5.5. My Route is..
Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function(){
Route::get('dashboard', ['as' => 'dashboardRoute', 'uses' => 'DashboardController@index']);
Route::resource('categories', 'CategoryController');
});
My blade view is..
<div id="2" class="collapse">
<a href="{{ route('admin.categories.index') }}" class="list-group-item small">Category</a>
</div>
Error is..
Route [admin.categories.index] not defined. (View: D:\XAMPPP\htdocs\dynamic_blog\resources\views\admin\sidebar.blade.php) (View: D:\XAMPPP\htdocs\dynamic_blog\resources\views\admin\sidebar.blade.php) (View: D:\XAMPPP\htdocs\dynamic_blog\resources\views\admin\sidebar.blade.php)
Upvotes: 1
Views: 1972
Reputation:
Add the as
index to the route group, that should prefix it with admin.
Route::group(['prefix' => 'admin', 'middleware' => 'auth', 'as' => 'admin.'], function(){
Route::get('dashboard', ['as' => 'dashboardRoute', 'uses' => 'DashboardController@index']);
Route::resource('categories', 'CategoryController');
});
Upvotes: 3
Reputation: 5083
Your routes are most likely cached.
Run
php artisan route:clear
to clear the route cache.
Upvotes: 0