Builds up routes for meta functionality of the CMS (such as localization).

@param Router $router
332964
protected function buildMetaRoutes(Router $router)
    {
        $router->group(
            [
                'prefix' => 'meta',
            ],
            function (Router $router) {

                $router->post('set-locale', [
                    'as'   => NamedRoute::LOCALE_SET,
                    'uses' => LocaleController::class . '@setLocale',
                ]);
            }
        );

    }
452333
public function loadModules(Router $router) {
        $this->modules = require_once BASE_DIR . '/config/modules.php';

        foreach ($this->modules['modules'] as $module) {
            if (!file_exists(MODULES_DIR . '/' . $module . '/Config/routes.php')) {
                throw new \Exception(_message(ExceptionMessages::MODULE_NOT_FOUND, $module));
            }

            $routesClosure = require_once MODULES_DIR . '/' . $module . '/Config/routes.php';

            if (!$routesClosure instanceof \Closure) {
                throw new \Exception(ExceptionMessages::ROUTES_NOT_CLOSURE);
            }

            $route = new Route($module);
            $routesClosure($route);
            $router->routes = $route->getRuntimeRoutes();
        }
    }
813394
function build(iRouterStack $router)
    {
        foreach($this->routes as $routeName => $routeValuable)
        {
            $route = $routeValuable;

            if ( is_string($routeName) && is_array($routeValuable) ) {
                // when route provided as array options
                $route = $this->_attainRouteFromArray($routeName, $routeValuable);
                $override = (isset($routeValuable['override']))  ? $routeValuable['override'] : true;
                $priority = (isset($routeValuable['priority']))  ? $routeValuable['priority'] : null;
            }

            if (! $route instanceof  iRoute )
                throw new \InvalidArgumentException(sprintf(
                    'Invalid argument provided. ("%s")'
                    , \Poirot\Std\flatten($routeValuable)
                ));



            # add router
            if ( isset($override) && isset($priority) )
                ## just if override option provided
                $router->add($route, $override, $priority);
            else
                ## using default value
                $router->add($route);
        }
    }
1322385
public function bind(Router $router)
    {
        $router->model('component', 'CachetHQ\Cachet\Models\Component');
        $router->model('component_group', 'CachetHQ\Cachet\Models\ComponentGroup');
        $router->model('incident', 'CachetHQ\Cachet\Models\Incident');
        $router->model('incident_template', 'CachetHQ\Cachet\Models\IncidentTemplate');
        $router->model('incident_update', 'CachetHQ\Cachet\Models\IncidentUpdate');
        $router->model('metric', 'CachetHQ\Cachet\Models\Metric');
        $router->model('metric_point', 'CachetHQ\Cachet\Models\MetricPoint');
        $router->model('schedule', 'CachetHQ\Cachet\Models\Schedule');
        $router->model('setting', 'CachetHQ\Cachet\Models\Setting');
        $router->model('subscriber', 'CachetHQ\Cachet\Models\Subscriber');
        $router->model('subscription', 'CachetHQ\Cachet\Models\Subscription');
        $router->model('tag', 'CachetHQ\Cachet\Models\Tag');
        $router->model('user', 'CachetHQ\Cachet\Models\User');
    }
925936
public function map(Router $router)
    {
        $this->app['events']->fire('routes.loading');

        foreach ($this->app['modules.loader']->getRegisteredModules() as $module) {
            $this->app->call([$module, 'loadRoutes'], [$router]);
        }

        $this->app['events']->fire('routes.loaded');
    }
845991
public function map(Router $router)
    {
        $router->bind('widget', function ($id) use ($router) {
            if ($router->is(admin_prefix() . '*')) {
                return Widget::withoutGlobalScope('menu_assignment')->findOrFail($id);
            }

            return Widget::findOrFail($id);
        });

        $this->mapWebRoutes($router);
    }
745998
public function map(Router $router)
    {
        /** @var Tenant $tenant */
        $tenant = $this->app->make('auth.tenant');
        $router->group(
            ['namespace' => $this->namespace],
            function ($router) use ($tenant) {
                $tries = ['routes'];

                if ($tenant->getTenantOwner() instanceof DomainAwareTenantParticipant) {
                    array_unshift($tries, $tenant->getTenantOwner()->getDomain());
                }
                if ($tenant->getTenantCreator() instanceof DomainAwareTenantParticipant) {
                    array_unshift($tries, $tenant->getTenantCreator()->getDomain());
                }

                foreach ($tries as $file) {
                    $path = app_path(sprintf('Http/%s.php', $file));
                    if (file_exists($path)) {
                        require_once $path;
                        return;
                    }
                }

                throw new \RuntimeException('No routes found in: ' . implode(', ', $tries));
            }
        );
    }
608103
public function boot(Router $router)
	{
		//============
		//== ASSETS ==
		//============
		$this->loadViewsFrom(__DIR__.'/../resources/views', static::PACKAGE_NAME);
		$this->loadViewsFrom(__DIR__.'/../resources/admin_views', static::PACKAGE_NAME . '_admin');
		
		$this->loadTranslationsFrom('/', 'common');
		
		$this->publishes([
			__DIR__.'/../database/migrations/' => database_path('/migrations')
		], 'migrations');
		
		$this->publishes([
			__DIR__.'/../assets/' => public_path('vendor/common'),
		], 'public');
		
		$this->publishes([
			__DIR__.'/../config/' . static::PACKAGE_NAME . '.php' => config_path('neonbug/' . static::PACKAGE_NAME . '.php'),
		]);
		
		//============
		//== ROUTES ==
		//============
		$language = App::make('Language');
		$locale = ($language == null ? Config::get('app.default_locale') : $language->locale);
		
		$admin_language = App::make('AdminLanguage');
		$admin_locale = ($admin_language == null ? Config::get('app.admin_default_locale') : $admin_language->locale);
		
		View::composer('common::admin', function($view) use ($router)
		{
			$menu_items = [];
			
			$routes = $router->getRoutes();
			foreach ($routes as $route)
			{
				if (stripos($route->getName(), '::admin::') !== false)
				{
					if (!in_array('admin.menu', $route->middleware())) continue;
					if (!in_array('GET', $route->getMethods())) continue; //only list routes for GET
					if (sizeof($route->parameterNames()) > 0) continue;
					
					//check for required role
					$action = $route->getAction();
					if (!array_key_exists('role', $action)) continue;
					
					$required_role = $action['role'];
					if ($required_role != '*')
					{
						$roles = Auth::user()->roles;
						$has_role = false;
						foreach ($roles as $role)
						{
							if ($role->id_role == 'admin' || /* admin has access to everything */
								$role->id_role == $required_role)
							{
								$has_role = true;
								break;
							}
						}
						if (!$has_role) continue;
					}
					
					//transform the route into menu item
					$arr = explode('::', $route->getName());
					if (!array_key_exists($arr[0], $menu_items))
					{
						$menu_items[$arr[0]] = [
							'title' => $arr[0], 
							'icon' => (array_key_exists('menu.icon', $route->getAction()) ? 
								$route->getAction()['menu.icon'] : 'arrow right'), 
							'weight' => (array_key_exists('weight', $route->getAction()) ? 
								$route->getAction()['weight'] : 5), 
							'items' => []
						];
					}
					$menu_items[$arr[0]]['items'][] = [
						'route' => $route->getName(), 
						'title' => $arr[2]
					];
				}
			}
			
			$view->menu_items = array_values($menu_items);
			
			$view->compact_admin_menu = Config::get('app.compact_admin_menu', false);
			
			usort($view->menu_items, function($a, $b) {
				if ($a['weight'] < $b['weight']) return -1;
				if ($a['weight'] > $b['weight']) return 1;
				return 0;
			});
			
			$view->withEncryptedCsrfToken(Crypt::encrypt(csrf_token()));
			$view->withUser(Auth::user());
		});
		
		view()->share('formatter', App::make('\Neonbug\Common\Helpers\FormatterHelper'));
		
		//admin
		$router->get('admin', function() { return redirect(route('admin-home')); });
		$router->group(['prefix' => $admin_locale . '/admin'], function($router)
		{
			$auth_controller = '\Neonbug\Common\Http\Controllers\Auth\AuthController';
			
			$router->get('login',  ['as' => 'admin-login',  'uses' => $auth_controller . '@getLogin']);
			$router->post('login', [                        'uses' => $auth_controller . '@postLogin']);
			$router->get('logout', ['as' => 'admin-logout', 'uses' => $auth_controller . '@getLogout']);
			
			$router->post('check-token', ['as' => 'admin-check-token', function() {
				return [ 'success' => true, 'token' => csrf_token() ];
			}]);
			$router->get('token', ['as' => 'admin-token', function() {
				return [ 'token' => csrf_token(), 'encrypted_token' => Crypt::encrypt(csrf_token()) ];
			}]);
		});
		
		$router->group(['prefix' => $admin_locale . '/admin', 'middleware' => ['auth.admin']], function($router)
		{
			$router->group(['role' => '*'], function($router) {
				$router->get('/', ['as' => 'admin-home', 
					'uses' => '\Neonbug\Common\Http\Controllers\AdminController@index']);
				$router->get('/dashboard/analytics-data', ['as' => 'admin-dashboard-analytics-data', 
					'uses' => '\Neonbug\Common\Http\Controllers\AdminController@getAnalyticsData']);
			});
		});
		
		//============
		//== EVENTS ==
		//============
		Event::subscribe('\Neonbug\Common\Handlers\Events\DropdownEventHandler');
		Event::subscribe('\Neonbug\Common\Handlers\Events\OrdEventHandler');
		Event::subscribe('\Neonbug\Common\Handlers\Events\PasswordHashEventHandler');
		Event::subscribe('\Neonbug\Common\Handlers\Events\SlugEventHandler');

		parent::boot($router);
	}
331249
public function setupRoutes(Router $router)
    {
        // by default, use the routes file provided in vendor
        $routeFilePathInUse = __DIR__.$this->routeFilePath;
        // but if there's a file with the same name in routes/backpack, use that one
        if (file_exists(base_path().$this->routeFilePath)) {
            $routeFilePathInUse = base_path().$this->routeFilePath;
        }
        $this->loadRoutesFrom($routeFilePathInUse);
    }
1339303
public function map(Router $router)
    {
        $router->group(['namespace' => $this->namespace], function (Router $router) {

            /*
             * Front office routes
             */
            if ($page = TypiCMS::getPageLinkedToModule('currencies')) {
                $options = $page->private ? ['middleware' => 'auth'] : [];
                foreach (config('translatable.locales') as $lang) {
                    if ($page->translate($lang)->status && $uri = $page->uri($lang)) {
                        $router->get($uri, $options + ['as' => $lang.'.currencies', 'uses' => 'PublicController@index']);
                        $router->get($uri.'/{slug}', $options + ['as' => $lang.'.currencies.slug', 'uses' => 'PublicController@show']);
                    }
                }
            }

            /*
             * Admin routes
             */
            $router->get('admin/currencies', 'AdminController@index')->name('admin::index-currencies');
            $router->get('admin/currencies/create', 'AdminController@create')->name('admin::create-currency');
            $router->get('admin/currencies/{currency}/edit', 'AdminController@edit')->name('admin::edit-currency');
            $router->post('admin/currencies', 'AdminController@store')->name('admin::store-currency');
            $router->put('admin/currencies/{currency}', 'AdminController@update')->name('admin::update-currency');

            /*
             * API routes
             */
            $router->get('api/currencies', 'ApiController@index')->name('api::index-currencies');
            $router->put('api/currencies/{currency}', 'ApiController@update')->name('api::update-currency');
            $router->delete('api/currencies/{currency}', 'ApiController@destroy')->name('api::destroy-currency');
        });
    }
518430
public function boot(Router $router)
	{
        $attributes = [
            'prefix'     => config('lia.route.prefix').'/trans',
            'namespace'  => 'Lia\Addons\TranslationManager',
            'middleware' => ['api', 'jwt.auth'],
            'as'         => 'trans.'
        ];

        $router->group($attributes, function($router)
        {
            $router->get('/{groupKey?}', 'Controller@getIndex')->where('groupKey', '.*')->name('getIndex');
            $router->post('/add/{groupKey}', 'Controller@postAdd')->where('groupKey', '.*')->name('postAdd');
            $router->post('/edit/{groupKey}', 'Controller@postEdit')->where('groupKey', '.*')->name('postEdit');
            $router->post('/groups/add', 'Controller@postAddGroup')->name('postAddGroup');
            $router->post('/delete/{groupKey}/{translationKey}', 'Controller@postDelete')->where('groupKey', '.*')->name('postDelete');
            $router->post('/import', 'Controller@postImport')->name('postImport');
            $router->post('/find', 'Controller@postFind')->name('postFind');
            $router->post('/locales/add', 'Controller@postAddLocale')->name('postAddLocale');
            $router->post('/locales/remove', 'Controller@postRemoveLocale')->name('postRemoveLocale');
            $router->post('/publish/{groupKey}', 'Controller@postPublish')->where('groupKey', '.*')->name('postPublish');
        });
	}
905261
public function map(Router $router)
    {
        $api = app('Dingo\Api\Routing\Router');

        $this->loadApiRoutes($api, $router);

        $router->group(['namespace' => $this->namespace], function (Router $router) {
            $this->loadBackendRoutes($router);
            $this->loadFrontendRoutes($router);
        });
    }
495702
public function mapApiRoutes(Router $router)
    {
        foreach ($this->modules as $module) {
            $module->mapApiRoutes($router);
        }
    }
229362
public function addRouter(Router $router, int $priority = null)
	{
		if ($priority !== null) {
			Arrays::slice($this->indexedRouters, $priority, $router);
		} else {
			$this->routers[] = $router;
		}
	}
226381
public function boot(Router $router)
    {
        $this->publishes([
            __DIR__ . '/Config/version.php' => config_path('version.php'),
        ], 'version');

        $this->app->singleton('version', function ($app) {
            return new Version($app);
        });
    }
779196
protected function mapAdministratorAuthenticationRoutes(Router $router)
    {
        $router->group(['prefix' => admin_prefix(), 'middleware' => 'web'], function () use ($router) {
            $router->get('login', AuthController::class . '@showLoginForm')->name('administrator.login');
            $router->get('logout', AuthController::class . '@logout')->name('administrator.logout');
            $router->post('login', AuthController::class . '@login')->name('administrator.login');
        });
    }
1045745
public function boot(Router $router)
  {
    $router->middleware('roles', \App\Http\Middleware\HasRole::class);
    $router->middleware('admin', \App\Http\Middleware\AdminMiddleware::class);
    if (! $this->app->routesAreCached()) {
      require __DIR__.'/Http/routes.php';
    }

    $configFiles = ['acl'];
    foreach ($configFiles as $config) {
      $this->mergeConfigFrom(__DIR__."/config/{$config}.php", 'acl');
    }

    $this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'acl');
    $this->loadViewsFrom(__DIR__ . '/resources/views', 'acl');

    //Publish middleware
    $this->publishes([
      __DIR__ . '/Middleware/' => app_path('Http/Middleware'),
    ]);

    //Publish providers
    $this->publishes([
      __DIR__ . '/Providers/' => app_path('Providers'),
    ]);

    //Publish views
    $this->publishes([
      // __DIR__.'/resources/views' => resource_path('views/vendor/user-auth'),
      __DIR__.'/resources/views' => resource_path('views'),
    ], 'views');

    //Publish translations
    $this->publishes([
      __DIR__.'/resources/lang/' => resource_path('lang/'),
      // __DIR__.'/resources/lang/pagination.php' => resource_path('lang/pagination.php'),
      // __DIR__.'/resources/lang/password.php' => resource_path('lang/password.php'),
      // __DIR__.'/resources/lang/validation.php' => resource_path('lang/validation.php'),
    ], 'translations');

    // Publish a config file
    $this->publishes([
      __DIR__.'/config/acl.php' => config_path('acl.php'),
    ], 'config');

    //Publish migrations
    $this->publishes([
      __DIR__ . '/database/migrations' => database_path('migrations'),
      __DIR__ . '/database/seeds' => database_path('seeds'),
    ], 'migrations');

    $this->publishes([
      __DIR__.'/assets/bower_components/AdminLTE/' => public_path('/assets/bower_components/AdminLTE/'),
    ], 'public');

    $this->publishes([
      __DIR__ . '/Http/Controllers/Auth/'    => app_path('/Http/Controllers/Auth/'),
      __DIR__ . '/Http/Controllers/Admin/'    => app_path('/Http/Controllers/Admin/'),
    ], 'controllers');
    $this->publishes([
      __DIR__ . '/Models/Admin/' => app_path(),
    ], 'models');
  }