Is there any way to define the name of route group in laravel?
What I\'m trying to accomplish by this is to know that the current request belongs to which group so I
This should work:
Route::group(['prefix'=>'accounts','as'=>'account.'], function(){
Route::get('/', ['as' => 'index', 'uses' => 'AccountController@index']);
Route::get('connect', ['as' => 'connect', 'uses' = > 'AccountController@connect']);
});
Look here for an explanation and in the official documentation (under Route Groups & Named Routes).
Update
{{ $routeName = \Request::route()->getName() }}
@if(strpos($routeName, 'account.') === 0)
// do something
@endif
Alternative from Rohit Khatri
function getCurrentRouteGroup() {
$routeName = Illuminate\Support\Facades\Route::current()->getName();
return explode('.',$routeName)[0];
}