Completed
Pull Request — master (#8)
by Troy
01:26
created

MultiTenantServiceProvider::boot()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 27
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
rs 8.8571
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
3
namespace MultiTenantLaravel;
4
5
use Illuminate\Support\ServiceProvider;
6
use MultiTenantLaravel\App\Commands\CreateTenant;
7
8
class MultiTenantServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13
    public function boot()
14
    {
15
        // Publish the configurable config file for the user
16
        $this->publishes([__DIR__.'/config/multi-tenant.php' => config_path('multi-tenant.php')], 'multi-tenant');
17
18
        // Make views publishable to the vendor folder in a project
19
        $this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/multi-tenant')]);
20
21
        // Load any routes
22
        $this->loadRoutesFrom(__DIR__.'/routes/routes.php');
23
24
        // Load any migrations
25
        $this->loadMigrationsFrom(__DIR__.'/database/migrations');
26
27
        // Load any views
28
        $this->loadViewsFrom(__DIR__.'/resources/views', 'multi-tenant');
29
30
        // Setup a middleware for the multi tenacy
31
        app('router')->aliasMiddleware('multi-tenant', \MultiTenantLaravel\App\Http\Middleware\MultiTenantMiddleware::class);
32
33
        // Register any commands we want available to the user
34
        if ($this->app->runningInConsole()) {
35
            $this->commands([
36
                CreateTenant::class,
37
            ]);
38
        }
39
    }
40
41
    /**
42
     * Register the application services.
43
     */
44
    public function register()
45
    {
46
        $this->mergeConfigFrom(__DIR__.'/config/config.php', 'multi-tenant-config');
47
    }
48
}
49