forked from musonza/chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatServiceProvider.php
More file actions
executable file
·78 lines (68 loc) · 1.57 KB
/
ChatServiceProvider.php
File metadata and controls
executable file
·78 lines (68 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
namespace Musonza\Chat;
use Illuminate\Support\ServiceProvider;
class ChatServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Bootstrap application services.
*
* @return void
*/
public function boot()
{
$this->publishMigrations();
$this->publishConfig();
if (config('musonza_chat.should_load_routes')) {
require __DIR__.'/Http/routes.php';
}
}
/**
* Register application services.
*
* @return void
*/
public function register()
{
$this->registerChat();
}
/**
* Registers Chat.
*
* @return void
*/
private function registerChat()
{
$this->app->bind('\Musonza\Chat\Chat', function () {
return $this->app->make(Chat::class);
});
}
/**
* Publish package's migrations.
*
* @return void
*/
public function publishMigrations()
{
$timestamp = date('Y_m_d_His', time());
$stub = __DIR__.'/../database/migrations/create_chat_tables.php';
$target = $this->app->databasePath().'/migrations/'.$timestamp.'_create_chat_tables.php';
$this->publishes([$stub => $target], 'chat.migrations');
}
/**
* Publish package's config file.
*
* @return void
*/
public function publishConfig()
{
$this->publishes([
__DIR__.'/../config' => config_path(),
], 'chat.config');
}
}