1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Cortex\Fort\Providers; |
6
|
|
|
|
7
|
|
|
use Illuminate\Routing\Router; |
8
|
|
|
use Illuminate\Support\ServiceProvider; |
9
|
|
|
use Cortex\Fort\Console\Commands\SeedCommand; |
10
|
|
|
|
11
|
|
|
class FortServiceProvider extends ServiceProvider |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* The commands to be registered. |
15
|
|
|
* |
16
|
|
|
* @var array |
17
|
|
|
*/ |
18
|
|
|
protected $commands = [ |
19
|
|
|
'SeedCommand' => 'command.rinvex.coworkit.seed', |
20
|
|
|
]; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Bootstrap any application services. |
24
|
|
|
* |
25
|
|
|
* @return void |
26
|
|
|
*/ |
27
|
|
|
public function boot(Router $router) |
28
|
|
|
{ |
29
|
|
|
// Load routes |
30
|
|
|
$this->loadRoutes($router); |
31
|
|
|
|
32
|
|
|
if ($this->app->runningInConsole()) { |
33
|
|
|
// Load migrations |
34
|
|
|
$this->loadMigrationsFrom(__DIR__.'/../../database/migrations'); |
35
|
|
|
|
36
|
|
|
// Publish Resources |
37
|
|
|
$this->publishResources(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
// Load views |
41
|
|
|
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'cortex/fort'); |
42
|
|
|
|
43
|
|
|
// Load language phrases |
44
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'cortex/fort'); |
45
|
|
|
|
46
|
|
|
// Register menu items |
47
|
|
|
$this->app['view']->composer('cortex/foundation::backend.partials.sidebar', function ($view) { |
|
|
|
|
48
|
|
|
app('menus.sidebar')->put('access', '<li class="header">'.trans('cortex/fort::navigation.headers.access').'</li>'); |
|
|
|
|
49
|
|
|
app('menus.sidebar')->put('access.abilities', '<li '.(strpos(request()->route()->getName(), 'backend.abilities.') === 0 ? 'class="active"' : '').'><a href="'.route('backend.abilities.index').'"><i class="fa fa-sliders"></i> <span>'.trans('cortex/fort::navigation.menus.abilities').'</span></a></li>'); |
|
|
|
|
50
|
|
|
app('menus.sidebar')->put('access.roles', '<li '.(strpos(request()->route()->getName(), 'backend.roles.') === 0 ? 'class="active"' : '').'><a href="'.route('backend.roles.index').'"><i class="fa fa-users"></i> <span>'.trans('cortex/fort::navigation.menus.roles').'</span></a></li>'); |
|
|
|
|
51
|
|
|
app('menus.sidebar')->put('access.users', '<li '.(strpos(request()->route()->getName(), 'backend.users.') === 0 ? 'class="active"' : '').'><a href="'.route('backend.users.index').'"><i class="fa fa-user"></i> <span>'.trans('cortex/fort::navigation.menus.users').'</span></a></li>'); |
|
|
|
|
52
|
|
|
}); |
53
|
|
|
|
54
|
|
|
// Register menu items |
55
|
|
|
$this->app['view']->composer('*.partials.header', function ($view) { |
|
|
|
|
56
|
|
|
app('menus.topbar')->put('user', view('cortex/fort::frontend.partials.topbar-user-menu')->render()); |
|
|
|
|
57
|
|
|
}); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Register any application services. |
62
|
|
|
* |
63
|
|
|
* This service provider is a great spot to register your various container |
64
|
|
|
* bindings with the application. As you can see, we are registering our |
65
|
|
|
* "Registrar" implementation here. You can add your own bindings too! |
66
|
|
|
* |
67
|
|
|
* @return void |
68
|
|
|
*/ |
69
|
|
|
public function register() |
70
|
|
|
{ |
71
|
|
|
if ($this->app->runningInConsole()) { |
72
|
|
|
// Register artisan commands |
73
|
|
|
foreach (array_keys($this->commands) as $command) { |
74
|
|
|
call_user_func_array([$this, "register{$command}Command"], []); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
$this->commands(array_values($this->commands)); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Register make auth command. |
83
|
|
|
* |
84
|
|
|
* @return void |
85
|
|
|
*/ |
86
|
|
|
protected function registerSeedCommandCommand() |
87
|
|
|
{ |
88
|
|
|
$this->app->singleton('command.rinvex.coworkit.seed', function ($app) { |
|
|
|
|
89
|
|
|
return new SeedCommand(); |
90
|
|
|
}); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Load the module routes. |
95
|
|
|
* |
96
|
|
|
* @param \Illuminate\Routing\Router $router |
97
|
|
|
* |
98
|
|
|
* @return void |
99
|
|
|
*/ |
100
|
|
|
public function loadRoutes(Router $router) |
101
|
|
|
{ |
102
|
|
|
// Load routes |
103
|
|
|
if ($this->app->routesAreCached()) { |
104
|
|
|
$this->app->booted(function () { |
105
|
|
|
require $this->app->getCachedRoutesPath(); |
106
|
|
|
}); |
107
|
|
|
} else { |
108
|
|
|
// Load Routes |
109
|
|
|
require __DIR__.'/../../routes/frontend.php'; |
110
|
|
|
require __DIR__.'/../../routes/backend.php'; |
111
|
|
|
|
112
|
|
|
$this->app->booted(function () use ($router) { |
113
|
|
|
$router->getRoutes()->refreshNameLookups(); |
114
|
|
|
}); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Publish resources. |
120
|
|
|
* |
121
|
|
|
* @return void |
122
|
|
|
*/ |
123
|
|
|
protected function publishResources() |
124
|
|
|
{ |
125
|
|
|
// Publish migrations |
126
|
|
|
$this->publishes([ |
127
|
|
|
realpath(__DIR__.'/../../database/migrations') => database_path('migrations'), |
128
|
|
|
], 'migrations'); |
129
|
|
|
|
130
|
|
|
// Publish views |
131
|
|
|
$this->publishes([ |
132
|
|
|
realpath(__DIR__.'/../../resources/views') => resource_path('views/vendor/cortex/fort'), |
133
|
|
|
], 'views'); |
134
|
|
|
|
135
|
|
|
// Publish language phrases |
136
|
|
|
$this->publishes([ |
137
|
|
|
realpath(__DIR__.'/../../resources/lang') => resource_path('lang/vendor/cortex/fort'), |
138
|
|
|
], 'lang'); |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.