1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sco\Admin\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Zizaco\Entrust\EntrustServiceProvider; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* |
10
|
|
|
*/ |
11
|
|
|
class AdminServiceProvider extends ServiceProvider |
12
|
|
|
{ |
13
|
|
|
protected $commands = [ |
14
|
|
|
\Sco\Admin\Commands\Install::class, |
15
|
|
|
]; |
16
|
|
|
|
17
|
|
|
protected $middlewares = [ |
18
|
|
|
'auth.admin' => \Sco\Admin\Middleware\AdminAuthenticate::class, |
19
|
|
|
'guest.admin' => \Sco\Admin\Middleware\RedirectIfAuthenticated::class, |
20
|
|
|
'admin.menu' => \Sco\Admin\Middleware\AdminMenu::class, |
21
|
|
|
]; |
22
|
|
|
|
23
|
|
|
public function getBasePath() |
24
|
|
|
{ |
25
|
|
|
return dirname(dirname(__DIR__)); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Bootstrap the application services. |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function boot() |
34
|
|
|
{ |
35
|
|
|
$this->registerMiddleware(); |
36
|
|
|
|
37
|
|
|
// 后台模板目录 |
38
|
|
|
$this->loadViewsFrom($this->getBasePath() . '/resources/admin', 'admin'); |
39
|
|
|
// 后台语言包目录 |
40
|
|
|
$this->loadTranslationsFrom($this->getBasePath() . '/resources/lang', 'Admin'); |
41
|
|
|
|
42
|
|
|
if ($this->app->runningInConsole()) { |
|
|
|
|
43
|
|
|
$this->loadMigrationsFrom($this->getBasePath() . '/database/migrations'); |
44
|
|
|
$this->publishAdmin(); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Register the application services. |
50
|
|
|
* |
51
|
|
|
* @return void |
52
|
|
|
*/ |
53
|
|
|
public function register() |
54
|
|
|
{ |
55
|
|
|
$this->app->register(RouteServiceProvider::class); |
56
|
|
|
|
57
|
|
|
//$this->commands($this->commands); |
|
|
|
|
58
|
|
|
|
59
|
|
|
$this->mergeConfigFrom($this->getBasePath() . '/config/admin.php', 'admin'); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
protected function registerMiddleware() |
63
|
|
|
{ |
64
|
|
|
$router = $this->app['router']; |
65
|
|
|
foreach ($this->middlewares as $key => $middleware) { |
66
|
|
|
$router->middleware($key, $middleware); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
protected function publishAdmin() |
71
|
|
|
{ |
72
|
|
|
$this->publishConfig(); |
73
|
|
|
$this->publishViews(); |
74
|
|
|
$this->publishTranslations(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
protected function publishConfig() |
78
|
|
|
{ |
79
|
|
|
$this->publishs([ |
|
|
|
|
80
|
|
|
$this->getBasePath() . '/config/admin.php' => config_path('admin.php'), |
81
|
|
|
$this->getBasePath() . '/config/entrust.php' => config_path('entrust.php'), |
82
|
|
|
], 'config'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
protected function publishViews() |
86
|
|
|
{ |
87
|
|
|
$this->publishs([ |
|
|
|
|
88
|
|
|
$this->getBasePath() . '/resources/views' => base_path('resources/views/vendor/admin'), |
89
|
|
|
], 'views'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
protected function publishTranslations() |
93
|
|
|
{ |
94
|
|
|
$this->publishs([ |
|
|
|
|
95
|
|
|
$this->getBasePath() . '/resources/lang' => base_path('resources/lang/vendor/admin'), |
96
|
|
|
], 'lang'); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
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.