How to define route group name in laravel

This should work:

Route::group(['prefix'=>'accounts','as'=>'account.'], function(){
    Route::get("https://stackoverflow.com/", ['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];
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)