1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Savannabits\JetstreamInertiaGenerator; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider; |
6
|
|
|
use Illuminate\Routing\Router; |
7
|
|
|
use Illuminate\Support\Facades\Route; |
8
|
|
|
use Savannabits\JetstreamInertiaGenerator\Helpers\JigInstaller; |
9
|
|
|
use Savannabits\JetstreamInertiaGenerator\Middleware\JigMiddleware; |
10
|
|
|
|
11
|
|
|
class JetstreamInertiaGeneratorServiceProvider extends RouteServiceProvider |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Bootstrap the application services. |
15
|
|
|
*/ |
16
|
|
|
public function boot() |
17
|
|
|
{ |
18
|
|
|
parent::boot(); |
19
|
|
|
$this->commands([ |
20
|
|
|
JetstreamInertiaGenerator::class, |
21
|
|
|
RoleGenerator::class, |
22
|
|
|
PermissionsGenerator::class, |
23
|
|
|
UsersGenerator::class, |
24
|
|
|
Generators\Model::class, |
25
|
|
|
Generators\Policy::class, |
26
|
|
|
Generators\Repository::class, |
27
|
|
|
Generators\ApiController::class, |
28
|
|
|
Generators\Controller::class, |
29
|
|
|
Generators\ViewIndex::class, |
30
|
|
|
Generators\ViewForm::class, |
31
|
|
|
Generators\ViewFullForm::class, |
32
|
|
|
Generators\ModelFactory::class, |
33
|
|
|
Generators\Routes::class, |
34
|
|
|
Generators\ApiRoutes::class, |
35
|
|
|
Generators\IndexRequest::class, |
36
|
|
|
Generators\StoreRequest::class, |
37
|
|
|
Generators\UpdateRequest::class, |
38
|
|
|
Generators\DestroyRequest::class, |
39
|
|
|
// Generators\ImpersonalLoginRequest::class, |
40
|
|
|
// Generators\BulkDestroyRequest::class, |
41
|
|
|
// Generators\Lang::class, |
42
|
|
|
Generators\Permissions::class, |
43
|
|
|
Generators\Export::class, |
44
|
|
|
]); |
45
|
|
|
/* |
46
|
|
|
* Optional methods to load your package assets |
47
|
|
|
*/ |
48
|
|
|
// $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'jetstream-inertia-generator'); |
49
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'jig'); |
50
|
|
|
// $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
51
|
|
|
/** |
52
|
|
|
* @var Router $router |
53
|
|
|
*/ |
54
|
|
|
$router = $this->app->make(Router::class); |
55
|
|
|
$router->aliasMiddleware('jig',JigMiddleware::class); |
56
|
|
|
if (file_exists(base_path('routes/jig.php'))) { |
57
|
|
|
|
58
|
|
|
$this->routes(function() { |
59
|
|
|
Route::middleware(['web','jig']) |
60
|
|
|
->namespace($this->namespace) |
61
|
|
|
->group(base_path('routes/jig.php')); |
62
|
|
|
}); |
63
|
|
|
} else { |
64
|
|
|
$this->loadRoutesFrom(__DIR__.'/routes.php'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
if ($this->app->runningInConsole()) { |
68
|
|
|
$this->publishes([ |
69
|
|
|
__DIR__.'/../config/config.php' => config_path('jig.php'), |
70
|
|
|
], 'jig-config'); |
71
|
|
|
|
72
|
|
|
// Publishing the views. |
73
|
|
|
$this->publishes([ |
74
|
|
|
__DIR__.'/../resources/published-views' => resource_path('views'), |
75
|
|
|
], 'jig-blade-templates'); |
76
|
|
|
|
77
|
|
|
$this->publishes([ |
78
|
|
|
__DIR__.'/../resources/js' => resource_path('js'), |
79
|
|
|
], 'jig-views'); |
80
|
|
|
|
81
|
|
|
$this->publishes([ |
82
|
|
|
__DIR__.'/../database/migrations' => database_path('migrations'), |
83
|
|
|
], 'jig-migrations'); |
84
|
|
|
|
85
|
|
|
$this->publishes([ |
86
|
|
|
__DIR__.'/../resources/compiler-configs' => base_path(''), |
87
|
|
|
], 'jig-compiler-configs'); |
88
|
|
|
|
89
|
|
|
$this->publishes([ |
90
|
|
|
__DIR__.'/routes.php' => base_path('routes/jig.php'), |
91
|
|
|
], 'jig-routes'); |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
// Publishing assets. |
95
|
|
|
$this->publishes([ |
96
|
|
|
__DIR__.'/../resources/assets' => public_path('vendor/jig'), |
97
|
|
|
], 'jig-assets'); |
98
|
|
|
|
99
|
|
|
// Publishing the translation files. |
100
|
|
|
/*$this->publishes([ |
101
|
|
|
__DIR__.'/../resources/lang' => resource_path('lang/vendor/jetstream-inertia-generator'), |
102
|
|
|
], 'lang');*/ |
103
|
|
|
|
104
|
|
|
// Registering package commands. |
105
|
|
|
$this->commands([JigInstaller::class]); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Register the application services. |
111
|
|
|
*/ |
112
|
|
|
public function register() |
113
|
|
|
{ |
114
|
|
|
parent::register(); |
115
|
|
|
// Automatically apply the package configuration |
116
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'jig'); |
117
|
|
|
// Register the main class to use with the facade |
118
|
|
|
$this->app->singleton('jetstream-inertia-generator', function () { |
119
|
|
|
return new JetstreamInertiaGenerator; |
120
|
|
|
}); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|