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
|
|
|
/** |
20
|
|
|
* Package name. |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $package = 'laravel-auth'; |
25
|
|
|
|
26
|
|
|
/* ----------------------------------------------------------------- |
27
|
|
|
| Main Methods |
28
|
|
|
| ----------------------------------------------------------------- |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Register the service provider. |
33
|
|
|
*/ |
34
|
231 |
|
public function register() |
35
|
|
|
{ |
36
|
231 |
|
parent::register(); |
37
|
|
|
|
38
|
231 |
|
$this->registerConfig(); |
39
|
231 |
|
$this->bindModels(); |
40
|
|
|
|
41
|
231 |
|
if ($this->config()->get('laravel-auth.events.enabled', false)) |
42
|
231 |
|
$this->registerProvider(Providers\EventServiceProvider::class); |
43
|
231 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Boot the service provider. |
47
|
|
|
*/ |
48
|
231 |
|
public function boot() |
49
|
|
|
{ |
50
|
231 |
|
parent::boot(); |
51
|
|
|
|
52
|
231 |
|
$this->publishConfig(); |
53
|
231 |
|
$this->publishFactories(); |
54
|
|
|
|
55
|
231 |
|
Auth::$runsMigrations ? $this->loadMigrations() : $this->publishMigrations(); |
56
|
231 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Get the services provided by the provider. |
60
|
|
|
* |
61
|
|
|
* @return array |
62
|
|
|
*/ |
63
|
3 |
|
public function provides() |
64
|
|
|
{ |
65
|
|
|
return [ |
66
|
|
|
// |
67
|
3 |
|
]; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/* ----------------------------------------------------------------- |
71
|
|
|
| Other Methods |
72
|
|
|
| ----------------------------------------------------------------- |
73
|
|
|
*/ |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Binding the models with the contracts. |
77
|
|
|
*/ |
78
|
231 |
|
private function bindModels() |
79
|
|
|
{ |
80
|
|
|
$bindings = [ |
81
|
231 |
|
'users' => AuthContracts\User::class, |
82
|
|
|
'roles' => AuthContracts\Role::class, |
83
|
|
|
'permissions' => AuthContracts\Permission::class, |
84
|
|
|
'permissions-groups' => AuthContracts\PermissionsGroup::class, |
85
|
|
|
]; |
86
|
|
|
|
87
|
231 |
|
foreach ($bindings as $key => $contract) { |
88
|
231 |
|
$this->bind($contract, $this->config()->get("laravel-auth.$key.model")); |
89
|
|
|
} |
90
|
231 |
|
} |
91
|
|
|
} |
92
|
|
|
|