|
1
|
|
|
<?php |
|
2
|
|
|
namespace Prateekkarki\Laragen; |
|
3
|
|
|
|
|
4
|
|
|
use Illuminate\Support\ServiceProvider; |
|
5
|
|
|
use Illuminate\Foundation\AliasLoader; |
|
6
|
|
|
use Intervention\Image\ImageServiceProvider; |
|
7
|
|
|
use Intervention\Image\Facades\Image; |
|
8
|
|
|
use Prateekkarki\Laragen\Commands\Generate; |
|
9
|
|
|
use Prateekkarki\Laragen\Commands\Seeder; |
|
10
|
|
|
use Prateekkarki\Laragen\Commands\Migrate; |
|
11
|
|
|
use Prateekkarki\Laragen\Commands\Execute; |
|
12
|
|
|
use Prateekkarki\Laragen\Models\LaragenOptions; |
|
13
|
|
|
use Spatie\Permission\PermissionServiceProvider; |
|
14
|
|
|
use Artisan; |
|
15
|
|
|
|
|
16
|
|
|
class LaragenServiceProvider extends ServiceProvider |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* Run on application loading |
|
20
|
|
|
*/ |
|
21
|
|
|
public function boot() |
|
22
|
|
|
{ |
|
23
|
|
|
$this->publishes([ |
|
24
|
|
|
__DIR__.'/../config/options.php' => config_path('laragen/options.php'), |
|
25
|
|
|
__DIR__.'/../config/modules.php' => config_path('laragen/modules.php') |
|
26
|
|
|
], 'config'); |
|
27
|
|
|
|
|
28
|
|
|
Artisan::call('vendor:publish', [ |
|
29
|
|
|
'--provider' => 'Prateekkarki\Laragen\LaragenServiceProvider' |
|
30
|
|
|
]); |
|
31
|
|
|
|
|
32
|
|
|
Artisan::call('vendor:publish', [ |
|
33
|
|
|
'--provider' => 'Spatie\Permission\PermissionServiceProvider' |
|
34
|
|
|
]); |
|
35
|
|
|
|
|
36
|
|
|
$file = app_path('Http/Helpers/laragen_helpers.php'); |
|
37
|
|
|
if (file_exists($file)) { |
|
38
|
|
|
require_once($file); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
/** |
|
43
|
|
|
* Run after all boot method completed |
|
44
|
|
|
*/ |
|
45
|
|
|
public function register() |
|
46
|
|
|
{ |
|
47
|
|
|
// Register Intervention Provider and Facade |
|
48
|
|
|
$this->app->register(PermissionServiceProvider::class); |
|
49
|
|
|
$this->app->register(ImageServiceProvider::class); |
|
50
|
|
|
AliasLoader::getInstance()->alias('Image', Image::class); |
|
51
|
|
|
|
|
52
|
|
|
$this->app->singleton('laragen', function() { |
|
53
|
|
|
return LaragenOptions::getInstance(); |
|
54
|
|
|
}); |
|
55
|
|
|
|
|
56
|
|
|
$this->app->bind('command.laragen:make', Generate::class); |
|
57
|
|
|
$this->app->bind('command.laragen:seed', Seeder::class); |
|
58
|
|
|
$this->app->bind('command.laragen:migrate', Migrate:: class); |
|
59
|
|
|
$this->app->bind('command.laragen:exec', Execute::class); |
|
60
|
|
|
|
|
61
|
|
|
$this->commands([ |
|
62
|
|
|
'command.laragen:make', |
|
63
|
|
|
'command.laragen:seed', |
|
64
|
|
|
'command.laragen:migrate', |
|
65
|
|
|
'command.laragen:exec', |
|
66
|
|
|
]); |
|
67
|
|
|
|
|
68
|
|
|
$routeFile = app_path('Providers/LaragenRouteServiceProvider.php'); |
|
69
|
|
|
$observerFile = app_path('Providers/LaragenObserverServiceProvider.php'); |
|
70
|
|
|
if (file_exists($routeFile)) { |
|
71
|
|
|
$this->app->register("\App\Providers\LaragenRouteServiceProvider"); |
|
72
|
|
|
} |
|
73
|
|
|
if (file_exists($observerFile)) { |
|
74
|
|
|
$this->app->register("\App\Providers\LaragenObserverServiceProvider"); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
/** |
|
78
|
|
|
* To register laragen as first level command. E.g. laragen:generate |
|
79
|
|
|
* |
|
80
|
|
|
* @return array |
|
81
|
|
|
*/ |
|
82
|
|
|
public function provides() |
|
83
|
|
|
{ |
|
84
|
|
|
return ['laragen']; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
|