|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ReliQArts\Mardin; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Foundation\AliasLoader; |
|
6
|
|
|
use Illuminate\Support\ServiceProvider; |
|
7
|
|
|
use ReliQArts\Mardin\Helpers\StringHelper; |
|
8
|
|
|
use Cmgmyr\Messenger\MessengerServiceProvider; |
|
9
|
|
|
use Illuminate\Database\Eloquent\Factory as EloquentFactory; |
|
10
|
|
|
|
|
11
|
|
|
class MardinServiceProvider extends ServiceProvider |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Indicates if loading of the provider is deferred. |
|
15
|
|
|
* |
|
16
|
|
|
* @var bool |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $defer = false; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* List of commands. |
|
22
|
|
|
* |
|
23
|
|
|
* @var array |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $commands = [ |
|
26
|
|
|
]; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Public asset files. |
|
30
|
|
|
*/ |
|
31
|
|
|
private function handleAssets() |
|
32
|
|
|
{ |
|
33
|
|
|
$this->publishes([ |
|
34
|
|
|
__DIR__.'/../public' => public_path('vendor/mardin'), |
|
35
|
|
|
], 'public'); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Configuration files. |
|
40
|
|
|
*/ |
|
41
|
|
|
private function handleConfigs() |
|
42
|
|
|
{ |
|
43
|
|
|
$configPath = __DIR__.'/../config/mardin.php'; |
|
44
|
|
|
|
|
45
|
|
|
// Allow publishing the config file, with tag: config |
|
46
|
|
|
$this->publishes([$configPath => config_path('mardin.php')], 'config'); |
|
47
|
|
|
|
|
48
|
|
|
// Merge config files... |
|
49
|
|
|
// Allows any modifications from the published config file to be seamlessly merged with default config file |
|
50
|
|
|
$this->mergeConfigFrom($configPath, 'mardin'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Translation files. |
|
55
|
|
|
*/ |
|
56
|
|
|
private function handleTranslations() |
|
57
|
|
|
{ |
|
58
|
|
|
// Load translations... |
|
59
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'mardin'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* View files. |
|
64
|
|
|
*/ |
|
65
|
|
|
private function handleViews() |
|
66
|
|
|
{ |
|
67
|
|
|
// Load the views... |
|
68
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'mardin'); |
|
69
|
|
|
|
|
70
|
|
|
// Allow publishing view files, with tag: views |
|
71
|
|
|
$this->publishes([ |
|
72
|
|
|
__DIR__.'/../resources/views' => base_path('resources/views/vendor/mardin'), |
|
73
|
|
|
], 'views'); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Migration files. |
|
78
|
|
|
*/ |
|
79
|
|
|
private function handleMigrations() |
|
80
|
|
|
{ |
|
81
|
|
|
// Load the migrations... |
|
82
|
|
|
$this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Route files. |
|
87
|
|
|
*/ |
|
88
|
|
|
private function handleRoutes() |
|
89
|
|
|
{ |
|
90
|
|
|
// Get the routes... |
|
91
|
|
|
require realpath(__DIR__.'/../routes/web.php'); |
|
92
|
|
|
require realpath(__DIR__.'/../routes/channels.php'); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Command files. |
|
97
|
|
|
*/ |
|
98
|
|
|
private function handleCommands() |
|
99
|
|
|
{ |
|
100
|
|
|
// Register the commands... |
|
101
|
|
|
if ($this->app->runningInConsole()) { |
|
102
|
|
|
$this->commands($this->commands); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Register factory files. |
|
108
|
|
|
* |
|
109
|
|
|
* @param string $path |
|
110
|
|
|
* @return void |
|
111
|
|
|
*/ |
|
112
|
|
|
protected function registerEloquentFactoriesFrom($path) |
|
113
|
|
|
{ |
|
114
|
|
|
$this->app->make(EloquentFactory::class)->load($path); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Bootstrap the application events. |
|
119
|
|
|
* |
|
120
|
|
|
* @return void |
|
121
|
|
|
*/ |
|
122
|
|
|
public function boot() |
|
123
|
|
|
{ |
|
124
|
|
|
$this->handleConfigs(); |
|
125
|
|
|
$this->handleMigrations(); |
|
126
|
|
|
$this->handleViews(); |
|
127
|
|
|
$this->handleTranslations(); |
|
128
|
|
|
$this->handleRoutes(); |
|
129
|
|
|
$this->handleCommands(); |
|
130
|
|
|
$this->handleAssets(); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Register the service provider. |
|
135
|
|
|
* |
|
136
|
|
|
* @return void |
|
137
|
|
|
*/ |
|
138
|
|
|
public function register() |
|
139
|
|
|
{ |
|
140
|
|
|
$loader = AliasLoader::getInstance(); |
|
141
|
|
|
|
|
142
|
|
|
// Register factories... |
|
143
|
|
|
$this->registerEloquentFactoriesFrom(__DIR__.'/../database/factories'); |
|
144
|
|
|
|
|
145
|
|
|
// Register service providers... |
|
146
|
|
|
$this->app->register(MessengerServiceProvider::class); |
|
147
|
|
|
|
|
148
|
|
|
// Register facades... |
|
149
|
|
|
$loader->alias('MardinStringHelper', StringHelper::class); |
|
150
|
|
|
|
|
151
|
|
|
// Bind contracts to models |
|
152
|
|
|
$this->app->bind( |
|
153
|
|
|
Contracts\User::class, |
|
154
|
|
|
config('mardin.user_model') |
|
155
|
|
|
); |
|
156
|
|
|
|
|
157
|
|
|
$this->app->bind( |
|
158
|
|
|
Contracts\UserTransformer::class, |
|
159
|
|
|
config('mardin.user_transformer') |
|
160
|
|
|
); |
|
161
|
|
|
|
|
162
|
|
|
$this->app->bind( |
|
163
|
|
|
Contracts\Message::class, |
|
164
|
|
|
config('mardin.message_model') |
|
165
|
|
|
); |
|
166
|
|
|
|
|
167
|
|
|
$this->app->bind( |
|
168
|
|
|
Contracts\Thread::class, |
|
169
|
|
|
config('mardin.thread_model') |
|
170
|
|
|
); |
|
171
|
|
|
|
|
172
|
|
|
$this->app->bind( |
|
173
|
|
|
Contracts\Participant::class, |
|
174
|
|
|
config('mardin.participant_model') |
|
175
|
|
|
); |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* Get the services provided by the provider. |
|
180
|
|
|
* |
|
181
|
|
|
* @return array |
|
182
|
|
|
*/ |
|
183
|
|
|
public function provides() |
|
184
|
|
|
{ |
|
185
|
|
|
return [ |
|
186
|
|
|
Contracts\User::class, |
|
187
|
|
|
Contracts\Thread::class, |
|
188
|
|
|
Contracts\Message::class, |
|
189
|
|
|
Contracts\Participant::class, |
|
190
|
|
|
Contracts\UserTransformer::class, |
|
191
|
|
|
]; |
|
192
|
|
|
} |
|
193
|
|
|
} |
|
194
|
|
|
|