|
1
|
|
|
<?php namespace Distilleries\DatatableBuilder; |
|
2
|
|
|
|
|
3
|
|
|
use Chumper\Datatable\Datatable; |
|
4
|
|
|
use Illuminate\Support\ServiceProvider; |
|
5
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
6
|
|
|
use Illuminate\Foundation\AliasLoader; |
|
7
|
|
|
|
|
8
|
|
|
class DatatableBuilderServiceProvider extends ServiceProvider { |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
protected $package = 'datatable-builder'; |
|
12
|
|
|
|
|
13
|
8 |
|
public function boot() |
|
14
|
|
|
{ |
|
15
|
8 |
|
$this->loadViewsFrom(__DIR__.'/../../views', $this->package); |
|
16
|
8 |
|
$this->loadTranslationsFrom(__DIR__.'/../../lang', $this->package); |
|
17
|
8 |
|
$this->publishes([ |
|
18
|
8 |
|
__DIR__.'/../../config/config.php' => config_path($this->package.'.php'), |
|
19
|
8 |
|
__DIR__.'/../../config/datatable.php' => config_path('chumper_datatable.php'), |
|
20
|
|
|
]); |
|
21
|
|
|
|
|
22
|
8 |
|
$this->publishes([ |
|
23
|
8 |
|
__DIR__.'/../../views' => base_path('resources/views/vendor/'.$this->package), |
|
24
|
8 |
|
], 'views'); |
|
25
|
|
|
|
|
26
|
8 |
|
$this->publishes([ |
|
27
|
8 |
|
__DIR__.'/../../resources/assets' => base_path('resources/assets/vendor/'.$this->package), |
|
28
|
8 |
|
], 'assets'); |
|
29
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Register the service provider. |
|
34
|
|
|
* |
|
35
|
|
|
* @return void |
|
36
|
|
|
*/ |
|
37
|
8 |
|
public function register() |
|
38
|
|
|
{ |
|
39
|
8 |
|
$this->mergeConfigFrom( |
|
40
|
8 |
|
__DIR__.'/../../config/config.php', |
|
41
|
8 |
|
$this->package |
|
42
|
|
|
); |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
$this->app->singleton('datatable',function() |
|
46
|
|
|
{ |
|
47
|
4 |
|
return new Datatable; |
|
48
|
8 |
|
}); |
|
49
|
|
|
|
|
50
|
8 |
|
$this->alias(); |
|
51
|
8 |
|
$this->registerCommands(new Filesystem); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Get the services provided by the provider. |
|
56
|
|
|
* |
|
57
|
|
|
* @return string[] |
|
58
|
|
|
*/ |
|
59
|
2 |
|
public function provides() |
|
60
|
|
|
{ |
|
61
|
2 |
|
return array('datatable'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @param Filesystem $filesystem |
|
67
|
|
|
*/ |
|
68
|
8 |
|
protected function registerCommands($filesystem) |
|
69
|
|
|
{ |
|
70
|
8 |
|
$files = $filesystem->allFiles(__DIR__.'/Console/'); |
|
71
|
|
|
|
|
72
|
8 |
|
foreach ($files as $file) |
|
73
|
|
|
{ |
|
74
|
8 |
|
if (strpos($file->getPathName(), 'Lib') === false) |
|
75
|
|
|
{ |
|
76
|
8 |
|
$this->commands('Distilleries\DatatableBuilder\Console\\'.preg_replace('/\.php/i', '', $file->getFilename())); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
8 |
|
public function alias() { |
|
84
|
|
|
|
|
85
|
8 |
|
AliasLoader::getInstance()->alias( |
|
86
|
8 |
|
'View', |
|
87
|
8 |
|
'Illuminate\Support\Facades\View' |
|
88
|
|
|
); |
|
89
|
8 |
|
AliasLoader::getInstance()->alias( |
|
90
|
8 |
|
'FormBuilder', |
|
91
|
8 |
|
'Distilleries\FormBuilder\Facades\FormBuilder' |
|
92
|
|
|
); |
|
93
|
8 |
|
AliasLoader::getInstance()->alias( |
|
94
|
8 |
|
'Input', |
|
95
|
8 |
|
'Illuminate\Support\Facades\Input' |
|
96
|
|
|
); |
|
97
|
8 |
|
AliasLoader::getInstance()->alias( |
|
98
|
8 |
|
'Schema', |
|
99
|
8 |
|
'Illuminate\Support\Facades\Schema' |
|
100
|
|
|
); |
|
101
|
8 |
|
AliasLoader::getInstance()->alias( |
|
102
|
8 |
|
'Route', |
|
103
|
8 |
|
'Illuminate\Support\Facades\Route' |
|
104
|
|
|
); |
|
105
|
|
|
} |
|
106
|
|
|
} |