/
MasterServiceProvider.php
108 lines (88 loc) · 2.44 KB
/
MasterServiceProvider.php
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
namespace Litepie\Master;
use Illuminate\Support\ServiceProvider;
use Litepie\Master\Masters;
class MasterServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;
/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
// Load view
$this->loadViewsFrom(__DIR__ . '/resources/views', 'master');
// Load translation
$this->loadTranslationsFrom(__DIR__ . '/resources/lang', 'master');
// Load migrations
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
// Call pblish redources function
$this->publishResources();
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->mergeConfig();
$this->registerFacade();
$this->app->register(\Litepie\Master\Providers\AuthServiceProvider::class);
$this->app->register(\Litepie\Master\Providers\RouteServiceProvider::class);
}
/**
* Register the vault facade without the user having to add it to the app.php file.
*
* @return void
*/
public function registerFacade() {
$this->app->bind('master', function($app)
{
return $this->app->make(Master::class);
});
}
/**
* Merges user's and master's configs.
*
* @return void
*/
protected function mergeConfig()
{
$this->mergeConfigFrom(
__DIR__ . '/config/master.php', 'master'
);
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return ['master'];
}
/**
* Publish resources.
*
* @return void
*/
private function publishResources()
{
// Publish configuration file
$this->publishes([__DIR__ . '/config/' => config_path('/')], 'config');
// Publish admin view
$this->publishes([__DIR__ . '/resources/views' => base_path('resources/views/vendor/master')], 'view');
// Publish language files
$this->publishes([__DIR__ . '/resources/lang' => base_path('resources/lang/vendor/master')], 'lang');
// Publish public files and assets.
$this->publishes([__DIR__ . '/public/' => public_path('/')], 'public');
}
}