|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Sco\Admin\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* |
|
9
|
|
|
*/ |
|
10
|
|
|
class AdminServiceProvider extends ServiceProvider |
|
11
|
|
|
{ |
|
12
|
|
|
protected $commands = [ |
|
13
|
|
|
\Sco\Admin\Commands\Install::class, |
|
14
|
|
|
]; |
|
15
|
|
|
|
|
16
|
|
|
protected $middlewares = [ |
|
17
|
|
|
'auth.admin' => \Sco\Admin\Http\Middleware\AdminAuthenticate::class, |
|
18
|
|
|
'guest.admin' => \Sco\Admin\Http\Middleware\RedirectIfAuthenticated::class, |
|
19
|
|
|
'admin.menu' => \Sco\Admin\Http\Middleware\AdminMenu::class, |
|
20
|
|
|
]; |
|
21
|
|
|
|
|
22
|
|
|
public function getBasePath() |
|
23
|
|
|
{ |
|
24
|
|
|
return dirname(dirname(__DIR__)); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Bootstrap the application services. |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
*/ |
|
32
|
|
|
public function boot() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->registerMiddleware(); |
|
35
|
|
|
|
|
36
|
|
|
// 路由文件 |
|
37
|
|
|
$this->loadRoutes(); |
|
38
|
|
|
|
|
39
|
|
|
// 后台模板目录 |
|
40
|
|
|
$this->loadViewsFrom($this->getBasePath() . '/resources/views', 'admin'); |
|
41
|
|
|
// 后台语言包目录 |
|
42
|
|
|
$this->loadTranslationsFrom($this->getBasePath() . '/resources/lang', 'Admin'); |
|
43
|
|
|
|
|
44
|
|
|
if ($this->app->runningInConsole()) { |
|
|
|
|
|
|
45
|
|
|
$this->loadMigrationsFrom($this->getBasePath() . '/database/migrations'); |
|
46
|
|
|
$this->publishAdmin(); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Register the application services. |
|
52
|
|
|
* |
|
53
|
|
|
* @return void |
|
54
|
|
|
*/ |
|
55
|
|
|
public function register() |
|
56
|
|
|
{ |
|
57
|
|
|
//$this->commands($this->commands); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
$this->mergeConfigFrom($this->getBasePath() . '/config/admin.php', 'admin'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
protected function loadRoutes() |
|
64
|
|
|
{ |
|
65
|
|
|
$routesFile = $this->getBasePath() . '/routes/admin.php'; |
|
66
|
|
|
if (file_exists(base_path('routes/admin.php'))) { |
|
67
|
|
|
$routesFile = base_path('routes/admin.php'); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
$this->loadRoutesFrom($routesFile); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
protected function registerMiddleware() |
|
74
|
|
|
{ |
|
75
|
|
|
$router = $this->app['router']; |
|
76
|
|
|
foreach ($this->middlewares as $key => $middleware) { |
|
77
|
|
|
$router->aliasMiddleware($key, $middleware); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
protected function publishAdmin() |
|
82
|
|
|
{ |
|
83
|
|
|
$this->publishAssets(); |
|
84
|
|
|
$this->publishConfig(); |
|
85
|
|
|
$this->publishViews(); |
|
86
|
|
|
$this->publishTranslations(); |
|
87
|
|
|
$this->publishRoutes(); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
protected function publishAssets() |
|
91
|
|
|
{ |
|
92
|
|
|
$this->publishes([ |
|
93
|
|
|
$this->getBasePath() . '/resources/assets' => base_path('resources/assets/admin'), |
|
94
|
|
|
], 'assets'); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
protected function publishConfig() |
|
98
|
|
|
{ |
|
99
|
|
|
$this->publishes([ |
|
100
|
|
|
$this->getBasePath() . '/config/admin.php' => config_path('admin.php'), |
|
101
|
|
|
$this->getBasePath() . '/config/entrust.php' => config_path('entrust.php'), |
|
102
|
|
|
], 'config'); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
protected function publishViews() |
|
106
|
|
|
{ |
|
107
|
|
|
$this->publishes([ |
|
108
|
|
|
$this->getBasePath() . '/resources/views' => base_path('resources/views/vendor/admin'), |
|
109
|
|
|
], 'views'); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
protected function publishTranslations() |
|
113
|
|
|
{ |
|
114
|
|
|
$this->publishes([ |
|
115
|
|
|
$this->getBasePath() . '/resources/lang' => base_path('resources/lang/vendor/admin'), |
|
116
|
|
|
], 'lang'); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
protected function publishRoutes() |
|
120
|
|
|
{ |
|
121
|
|
|
$this->publishes([ |
|
122
|
|
|
$this->getBasePath() . '/routes/admin.php' => base_path('routes/admin.php') |
|
123
|
|
|
], 'routes'); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.