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', |
39
|
|
|
'admin'); |
40
|
|
|
// 后台语言包目录 |
41
|
|
|
$this->loadTranslationsFrom($this->getBasePath() . '/resources/lang', |
42
|
|
|
'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->app->register(RouteServiceProvider::class); |
58
|
|
|
|
59
|
|
|
//$this->commands($this->commands); |
|
|
|
|
60
|
|
|
|
61
|
|
|
$this->mergeConfigFrom($this->getBasePath() . '/config/admin.php', |
62
|
|
|
'admin'); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
protected function registerMiddleware() |
66
|
|
|
{ |
67
|
|
|
$router = $this->app['router']; |
68
|
|
|
foreach ($this->middlewares as $key => $middleware) { |
69
|
|
|
$router->middleware($key, $middleware); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
protected function publishAdmin() |
74
|
|
|
{ |
75
|
|
|
$this->publishAssets(); |
76
|
|
|
$this->publishConfig(); |
77
|
|
|
$this->publishViews(); |
78
|
|
|
$this->publishTranslations(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
protected function publishAssets() |
82
|
|
|
{ |
83
|
|
|
$this->publishes([ |
84
|
|
|
$this->getBasePath() . '/resources/assets' => base_path('resources/assets/admin'), |
85
|
|
|
], 'assets'); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
protected function publishConfig() |
89
|
|
|
{ |
90
|
|
|
$this->publishes([ |
91
|
|
|
$this->getBasePath() . '/config/admin.php' => config_path('admin.php'), |
92
|
|
|
$this->getBasePath() . '/config/entrust.php' => config_path('entrust.php'), |
93
|
|
|
], 'config'); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
protected function publishViews() |
97
|
|
|
{ |
98
|
|
|
$this->publishes([ |
99
|
|
|
$this->getBasePath() . '/resources/views' => base_path('resources/views/vendor/admin'), |
100
|
|
|
], 'views'); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
protected function publishTranslations() |
104
|
|
|
{ |
105
|
|
|
$this->publishes([ |
106
|
|
|
$this->getBasePath() . '/resources/lang' => base_path('resources/lang/vendor/admin'), |
107
|
|
|
], 'lang'); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
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.