1
votes

I am trying to set up a Laravel route group in Laravel 5.5 and use it in a blade. However I am getting the a Route not defined error. The full error is :

"Route [admin/route_group_test] not defined. (View: C:\Users\Joey\Web\jrd_dnd_tools\resources\views\layouts\navigation.blade.php) (View: C:\Users\Joey\Web\jrd_dnd_tools\resources\views\layouts\navigation.blade.php) (View: C:\Users\Joey\Web\jrd_dnd_tools\resources\views\layouts\navigation.blade.php)

I have looked through the documentation and it looks like I am doing it right. Here is the line from the route file:

Route::prefix('admin')->group(function(){
     Route::get('route_group_test','AdminController@testingMiddleWare');
});

and the link from the blade:

{{route('admin/route_group_test')}}

I have no idea what I am doing wrong

2

2 Answers

1
votes

The route() helper uses route's name. From the docs:

The route function generates a URL for the given named route

So you need to name the route:

Route::get('route_group_test', 'AdminController@testingMiddleWare')->name('admin.route_group_test');

Or:

Route::get('route_group_test', ['as' => 'admin.route_group_test', 'uses' => 'AdminController@testingMiddleWare']);

And then use it:

{{ route('admin.route_group_test') }}

Or you can use unnamed route:

{{ url('admin/route_group_test') }}
0
votes

Try the below code:

Route::group(['prefix'=>'admin','namespace'=>''], function () {
    Route::get('route_group_test','AdminController@testingMiddleWare');
});