|
1
|
|
|
<?php namespace Arcanedev\LaravelMessenger; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanedev\Support\PackageServiceProvider; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class LaravelMessengerServiceProvider |
|
7
|
|
|
* |
|
8
|
|
|
* @package Arcanedev\LaravelMessenger |
|
9
|
|
|
* @author ARCANEDEV <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class LaravelMessengerServiceProvider extends PackageServiceProvider |
|
12
|
|
|
{ |
|
13
|
|
|
/* ----------------------------------------------------------------- |
|
14
|
|
|
| Properties |
|
15
|
|
|
| ----------------------------------------------------------------- |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Package name. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $package = 'laravel-messenger'; |
|
24
|
|
|
|
|
25
|
|
|
/* ----------------------------------------------------------------- |
|
26
|
|
|
| Main Methods |
|
27
|
|
|
| ----------------------------------------------------------------- |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Register the service provider. |
|
32
|
|
|
*/ |
|
33
|
126 |
|
public function register() |
|
34
|
|
|
{ |
|
35
|
126 |
|
parent::register(); |
|
36
|
|
|
|
|
37
|
126 |
|
$this->registerConfig(); |
|
38
|
126 |
|
$this->bindModels(); |
|
39
|
126 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Boot the service provider. |
|
43
|
|
|
*/ |
|
44
|
126 |
|
public function boot() |
|
45
|
|
|
{ |
|
46
|
126 |
|
parent::boot(); |
|
47
|
|
|
|
|
48
|
126 |
|
$this->publishConfig(); |
|
49
|
|
|
|
|
50
|
126 |
|
Messenger::$runsMigrations ? $this->loadMigrations() : $this->publishMigrations(); |
|
51
|
126 |
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get the services provided by the provider. |
|
55
|
|
|
* |
|
56
|
|
|
* @return array |
|
57
|
|
|
*/ |
|
58
|
3 |
|
public function provides() |
|
59
|
|
|
{ |
|
60
|
|
|
return [ |
|
61
|
3 |
|
Contracts\Discussion::class, |
|
62
|
1 |
|
Contracts\Message::class, |
|
63
|
1 |
|
Contracts\Participant::class, |
|
64
|
1 |
|
]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/* ----------------------------------------------------------------- |
|
68
|
|
|
| Other Methods |
|
69
|
|
|
| ----------------------------------------------------------------- |
|
70
|
|
|
*/ |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Bind the models. |
|
74
|
|
|
*/ |
|
75
|
126 |
|
private function bindModels() |
|
76
|
|
|
{ |
|
77
|
126 |
|
$config = $this->config(); |
|
78
|
|
|
$bindings = [ |
|
79
|
126 |
|
'discussions' => Contracts\Discussion::class, |
|
80
|
42 |
|
'messages' => Contracts\Message::class, |
|
81
|
42 |
|
'participants' => Contracts\Participant::class, |
|
82
|
42 |
|
]; |
|
83
|
|
|
|
|
84
|
126 |
|
foreach ($bindings as $key => $contract) { |
|
85
|
126 |
|
$this->bind($contract, $config->get("{$this->package}.{$key}.model")); |
|
86
|
42 |
|
} |
|
87
|
126 |
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|