Completed
Pull Request — master (#23)
by ARCANEDEV
09:00
created

LaravelAuthServiceProvider::provides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Arcanedev\LaravelAuth;
2
3
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
4
use Arcanesoft\Contracts\Auth\Models as AuthContracts;
5
6
/**
7
 * Class     LaravelAuthServiceProvider
8
 *
9
 * @package  Arcanedev\LaravelAuth
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class LaravelAuthServiceProvider extends ServiceProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Properties
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'laravel-auth';
24
25
    /* ------------------------------------------------------------------------------------------------
26
     |  Getters & Setters
27
     | ------------------------------------------------------------------------------------------------
28
     */
29
    /**
30
     * Get the base path of the package.
31
     *
32
     * @return string
33
     */
34 225
    public function getBasePath()
35
    {
36 225
        return dirname(__DIR__);
37
    }
38
39
    /* ------------------------------------------------------------------------------------------------
40
     |  Main Functions
41
     | ------------------------------------------------------------------------------------------------
42
     */
43
    /**
44
     * Register the service provider.
45
     */
46 225
    public function register()
47
    {
48 225
        $this->registerConfig();
49 225
        $this->bindModels();
50
51 225
        if ($this->config()->get('laravel-auth.observers.enabled', false))
52 225
            $this->registerProvider(Providers\EventServiceProvider::class);
53 225
    }
54
55
    /**
56
     * Boot the service provider.
57
     */
58 225
    public function boot()
59
    {
60 225
        parent::boot();
61
62 225
        $this->publishConfig();
63 225
        $this->publishFactories();
64 225
        Auth::$runsMigrations
65
            ? $this->loadMigrations()
66 225
            : $this->publishMigrations();
67 225
    }
68
69
    /**
70
     * Get the services provided by the provider.
71
     *
72
     * @return array
73
     */
74 3
    public function provides()
75
    {
76
        return [
77
            //
78 3
        ];
79
    }
80
81
    /* ------------------------------------------------------------------------------------------------
82
     |  Other Functions
83
     | ------------------------------------------------------------------------------------------------
84
     */
85
    /**
86
     * Binding the models with the contracts.
87
     */
88 225
    private function bindModels()
89
    {
90
        $bindings = [
91 225
            'users'              => AuthContracts\User::class,
92
            'roles'              => AuthContracts\Role::class,
93
            'permissions'        => AuthContracts\Permission::class,
94
            'permissions-groups' => AuthContracts\PermissionsGroup::class,
95
        ];
96
97 225
        foreach ($bindings as $key => $contract) {
98 225
            $this->bind($contract, $this->config()->get("laravel-auth.$key.model"));
99
        }
100 225
    }
101
}
102