1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bhavingajjar\LaravelApiGenerator; |
4
|
|
|
|
5
|
|
|
use Bhavingajjar\LaravelApiGenerator\Commands\GenerateApi; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
|
8
|
|
|
class LaravelApiGeneratorServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* Bootstrap the application services. |
12
|
|
|
*/ |
13
|
|
|
public function boot() |
14
|
|
|
{ |
15
|
|
|
/* |
16
|
|
|
* Optional methods to load your package assets |
17
|
|
|
*/ |
18
|
|
|
// $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-api-generator'); |
19
|
|
|
// $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-api-generator'); |
20
|
|
|
// $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
21
|
|
|
// $this->loadRoutesFrom(__DIR__.'/routes.php'); |
22
|
|
|
|
23
|
|
|
if ($this->app->runningInConsole()) { |
24
|
|
|
$this->publishes([ |
25
|
|
|
__DIR__.'/../config/config.php' => config_path('laravel-api-generator.php'), |
26
|
|
|
], 'config'); |
27
|
|
|
|
28
|
|
|
// Publishing the views. |
29
|
|
|
/*$this->publishes([ |
30
|
|
|
__DIR__.'/../resources/views' => resource_path('views/vendor/laravel-api-generator'), |
31
|
|
|
], 'views');*/ |
32
|
|
|
|
33
|
|
|
// Publishing assets. |
34
|
|
|
/*$this->publishes([ |
35
|
|
|
__DIR__.'/../resources/assets' => public_path('vendor/laravel-api-generator'), |
36
|
|
|
], 'assets');*/ |
37
|
|
|
|
38
|
|
|
// Publishing the translation files. |
39
|
|
|
/*$this->publishes([ |
40
|
|
|
__DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-api-generator'), |
41
|
|
|
], 'lang');*/ |
42
|
|
|
|
43
|
|
|
// Registering package commands. |
44
|
|
|
$this->commands([ |
45
|
|
|
GenerateApi::class, |
46
|
|
|
]); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Register the application services. |
52
|
|
|
*/ |
53
|
|
|
public function register() |
54
|
|
|
{ |
55
|
|
|
// Automatically apply the package configuration |
56
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-api-generator'); |
57
|
|
|
|
58
|
|
|
// Register the main class to use with the facade |
59
|
|
|
$this->app->singleton('laravel-api-generator', function (string $model) { |
60
|
|
|
return new LaravelApiGenerator($model); |
61
|
|
|
}); |
62
|
|
|
|
63
|
|
|
$this->app['router']->middleware('ApiHeaderInject', 'Bhavingajjar\LaravelApiGenerator\Middleware\ApiHeaderInject'); |
64
|
|
|
|
65
|
|
|
$this->app['router']->aliasMiddleware('ApiHeaderInject', \Bhavingajjar\LaravelApiGenerator\Middleware\ApiHeaderInject::class); |
66
|
|
|
$this->app['router']->pushMiddlewareToGroup('api', \Bhavingajjar\LaravelApiGenerator\Middleware\ApiHeaderInject::class); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|