1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Backpack\Base; |
4
|
|
|
|
5
|
|
|
use Illuminate\Routing\Router; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Route; |
8
|
|
|
|
9
|
|
|
class BaseServiceProvider extends ServiceProvider |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* Indicates if loading of the provider is deferred. |
13
|
|
|
* |
14
|
|
|
* @var bool |
15
|
|
|
*/ |
16
|
|
|
protected $defer = false; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Perform post-registration booting of services. |
20
|
|
|
* |
21
|
|
|
* @return void |
22
|
|
|
*/ |
23
|
|
|
public function boot(\Illuminate\Routing\Router $router) |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
// LOAD THE VIEWS |
26
|
|
|
// - first the published views (in case they have any changes) |
27
|
|
|
$this->loadViewsFrom(resource_path('views/vendor/backpack/base'), 'backpack'); |
28
|
|
|
// - then the stock views that come with the package, in case a published view might be missing |
29
|
|
|
$this->loadViewsFrom(realpath(__DIR__.'/resources/views'), 'backpack'); |
30
|
|
|
|
31
|
|
|
$this->loadTranslationsFrom(realpath(__DIR__.'/resources/lang'), 'backpack'); |
32
|
|
|
|
33
|
|
|
// use the vendor configuration file as fallback |
34
|
|
|
$this->mergeConfigFrom( |
35
|
|
|
__DIR__.'/config/backpack/base.php', 'backpack.base' |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$this->setupRoutes($this->app->router); |
|
|
|
|
39
|
|
|
|
40
|
|
|
// ------------- |
41
|
|
|
// PUBLISH FILES |
42
|
|
|
// ------------- |
43
|
|
|
// publish config file |
44
|
|
|
$this->publishes([__DIR__.'/config' => config_path()], 'config'); |
45
|
|
|
// publish lang files |
46
|
|
|
$this->publishes([__DIR__.'/resources/lang' => resource_path('lang/vendor/backpack')], 'lang'); |
47
|
|
|
// publish views |
48
|
|
|
$this->publishes([__DIR__.'/resources/views' => resource_path('views/vendor/backpack/base')], 'views'); |
49
|
|
|
// publish error views |
50
|
|
|
$this->publishes([__DIR__.'/resources/error_views' => resource_path('views/errors')], 'errors'); |
51
|
|
|
// publish public Backpack assets |
52
|
|
|
$this->publishes([__DIR__.'/public' => public_path('vendor/backpack')], 'public'); |
53
|
|
|
// publish public AdminLTE assets |
54
|
|
|
$this->publishes([base_path('vendor/almasaeed2010/adminlte') => public_path('vendor/adminlte')], 'adminlte'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Define the routes for the application. |
59
|
|
|
* |
60
|
|
|
* @param \Illuminate\Routing\Router $router |
61
|
|
|
* |
62
|
|
|
* @return void |
63
|
|
|
*/ |
64
|
|
|
public function setupRoutes(Router $router) |
65
|
|
|
{ |
66
|
|
|
// register the 'admin' middleware |
67
|
|
|
$router->middleware('admin', app\Http\Middleware\Admin::class); |
68
|
|
|
|
69
|
|
|
$router->group(['namespace' => 'Backpack\Base\app\Http\Controllers'], function ($router) { |
|
|
|
|
70
|
|
|
Route::group( |
71
|
|
|
[ |
72
|
|
|
'middleware' => 'web', |
73
|
|
|
'prefix' => config('backpack.base.route_prefix') |
74
|
|
|
], |
75
|
|
|
function () { |
76
|
|
|
// if not otherwise configured, setup the auth routes |
77
|
|
|
if (config('backpack.base.setup_auth_routes')) { |
78
|
|
|
Route::auth(); |
79
|
|
|
Route::get('logout', 'Auth\LoginController@logout'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
// if not otherwise configured, setup the dashboard routes |
83
|
|
|
if (config('backpack.base.setup_dashboard_routes')) { |
84
|
|
|
Route::get('dashboard', 'AdminController@dashboard'); |
85
|
|
|
Route::get('/', 'AdminController@redirect'); |
86
|
|
|
} |
87
|
|
|
}); |
88
|
|
|
}); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Register any package services. |
93
|
|
|
* |
94
|
|
|
* @return void |
95
|
|
|
*/ |
96
|
|
|
public function register() |
97
|
|
|
{ |
98
|
|
|
// register the current package |
99
|
|
|
$this->app->bind('base', function ($app) { |
100
|
|
|
return new Base($app); |
101
|
|
|
}); |
102
|
|
|
|
103
|
|
|
// register its dependencies |
104
|
|
|
$this->app->register(\Jenssegers\Date\DateServiceProvider::class); |
105
|
|
|
$this->app->register(\Prologue\Alerts\AlertsServiceProvider::class); |
106
|
|
|
|
107
|
|
|
// register their aliases |
108
|
|
|
$loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
109
|
|
|
$loader->alias('Alert', \Prologue\Alerts\Facades\Alert::class); |
110
|
|
|
$loader->alias('Date', \Jenssegers\Date\Date::class); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.