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

MultiTenantServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B boot() 0 27 2
A register() 0 4 1
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