Illuminate\Routing\Router::group PHP Method

group() public method

Create a route group with shared attributes.
public group ( array $attributes, Closure $callback ) : void
$attributes array
$callback Closure
return void
    public function group(array $attributes, Closure $callback)
    {
        $this->updateGroupStack($attributes);
        // Once we have updated the group stack, we will execute the user Closure and
        // merge in the groups attributes when the route is created. After we have
        // run the callback, we will pop the attributes off of this group stack.
        call_user_func($callback, $this);
        array_pop($this->groupStack);
    }

Usage Example

 public function boot(Router $router)
 {
     $this->commands(Install::class);
     foreach ($this->routeMiddleware as $key => $middleware) {
         $router->middleware($key, $middleware);
     }
     $groupOptions = ['namespace' => $this->namespace];
     if (config('adminPanel.subDomain')) {
         $groupOptions['domain'] = config('adminPanel.routePrefix') . '.' . preg_replace("/^(.*?)\\.(.*)\$/", "\$2", \Request::server('SERVER_NAME'));
     } else {
         $groupOptions['prefix'] = config('adminPanel.routePrefix');
     }
     $router->group($groupOptions, function (Router $router) {
         $router->controller('auth', 'Auth\\AuthController', ['getRegister' => 'admin.register', 'getLogin' => 'admin.login', 'getLogout' => 'admin.logout']);
         $router->group(['middleware' => 'ap.permission', 'permission' => config('adminPanel.ap_permission')], function (Router $route) {
             $route->get('/', ['as' => 'admin.home', function () {
                 return view('adminPanel::hello');
             }]);
             $route->controller('ajax', 'AjaxController');
             $route->resource('user', 'UserController', ['as' => 'admin']);
             $route->model('role', config('entrust.role'));
             $route->resource('role', 'RoleController', ['as' => 'admin']);
             $route->model('permission', config('entrust.permission'));
             $route->resource('permission', 'PermissionController', ['as' => 'admin']);
         });
     });
     $this->loadViewsFrom(__DIR__ . '/../../resources/views', 'adminPanel');
     $this->publishes([__DIR__ . '/../../config/config.php' => config_path('adminPanel.php')], 'config');
     $this->publishes([__DIR__ . '/../../resources/assets' => base_path('resources/adminAssets')], 'assets');
     $this->publishes([__DIR__ . '/../../migrations' => base_path('database/migrations')], 'migrate');
 }
All Usage Examples Of Illuminate\Routing\Router::group