Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Providers;
- use Illuminate\Support\ServiceProvider;
- use Illuminate\Support\Facades\Route;
- use App\Tenant\ManagerTenant;
- use Illuminate\Support\Facades\View;
- class TenantServiceProvider extends ServiceProvider
- {
- /**
- * Bootstrap services.
- *
- * @return void
- */
- public function boot()
- {
- $manager = app(ManagerTenant::class);
- if ($manager->domainIsMain())
- {
- $this->registerTenantRoutes();
- $this->registerTenantAdminRoutes();
- }
- //Auto detect admin views
- View::addNamespace('admin', resource_path().'/views/admin/');
- }
- private function registerTenantRoutes()
- {
- Route::group($this->tenantRouteConfiguration(), function () {
- $route_file = config('tenant.routes.frontend');
- if(!file_exists($route_file)){
- throw new \Exception(trans('tenant.tenant_route'));
- return;
- }
- require $route_file;
- });
- }
- private function registerTenantAdminRoutes()
- {
- Route::group($this->tenantAdminRouteConfiguration(), function () {
- $admin_route_file = config('tenant.routes.backend');
- if(!file_exists($admin_route_file)){
- throw new \Exception(trans('tenant.tenant_admin_route'));
- }
- require $admin_route_file;
- });
- }
- private function tenantRouteConfiguration()
- {
- return [
- 'namespace' => config('tenant.namespaces.frontend'),
- 'middleware' => config('tenant.middlewares.frontend'),
- ];
- }
- private function tenantAdminRouteConfiguration()
- {
- return [
- 'namespace' => config('tenant.namespaces.backend'),
- 'middleware' => config('tenant.middlewares.backend'),
- ];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement