1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Akibatech\Crud; |
4
|
|
|
|
5
|
|
|
use Akibatech\Crud\Console\CrudControllerMakeCommand; |
6
|
|
|
use Illuminate\Support\Facades\Blade; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class CrudServiceProvider |
11
|
|
|
* |
12
|
|
|
* @package Akibatech\Crud |
13
|
|
|
*/ |
14
|
|
|
class CrudServiceProvider extends ServiceProvider |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @param void |
18
|
|
|
* @return void |
19
|
|
|
*/ |
20
|
|
|
public function boot() |
21
|
|
|
{ |
22
|
|
|
if ($this->app->runningInConsole()) |
23
|
|
|
{ |
24
|
|
|
$this->commands([ |
25
|
|
|
CrudControllerMakeCommand::class |
26
|
|
|
]); |
27
|
|
|
|
28
|
|
|
$this->publishes([ |
29
|
|
|
__DIR__ . '/../resources/lang/' => resource_path('lang/vendor/crud'), |
30
|
|
|
], 'crud'); |
31
|
|
|
|
32
|
|
|
$this->publishes([ |
33
|
|
|
__DIR__ . '/../resources/views/' => resource_path('views/vendor/crud'), |
34
|
|
|
], 'crud'); |
35
|
|
|
|
36
|
|
|
$this->publishes([ |
37
|
|
|
__DIR__ . '/../resources/assets/' => public_path('vendor/crud'), |
38
|
|
|
], 'crud'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
if ($this->app->runningUnitTests()) |
42
|
|
|
{ |
43
|
|
|
$this->loadViewsFrom(__DIR__ . '/../resources/views/', 'crud'); |
44
|
|
|
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang/', 'crud'); |
45
|
|
|
} |
46
|
|
|
else |
47
|
|
|
{ |
48
|
|
|
$this->loadViewsFrom(resource_path('views/vendor/crud'), 'crud'); |
49
|
|
|
$this->loadTranslationsFrom(resource_path('lang/vendor/crud'), 'crud'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
Blade::directive('crudtable', function($expression) { |
53
|
|
|
return "<?php echo crud_table($expression); ?>"; |
54
|
|
|
}); |
55
|
|
|
|
56
|
|
|
Blade::directive('crudentry', function($expression) { |
57
|
|
|
return "<?php echo crud_entry($expression); ?>"; |
58
|
|
|
}); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param void |
63
|
|
|
* @return void |
64
|
|
|
*/ |
65
|
|
|
public function register() |
66
|
|
|
{ |
67
|
|
|
$this->app->bind('Akibatech\Crud\Crud', Crud::class); |
68
|
|
|
$this->app->alias('Akibatech\Crud\Crud', 'crud'); |
69
|
|
|
|
70
|
|
|
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
71
|
|
|
$loader->alias('Crud', 'Akibatech\Crud\CrudFacade'); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|