1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Cortex\Statistics\Providers; |
6
|
|
|
|
7
|
|
|
use Illuminate\Routing\Router; |
8
|
|
|
use Illuminate\Support\ServiceProvider; |
9
|
|
|
use Rinvex\Support\Traits\ConsoleTools; |
10
|
|
|
use Cortex\Statistics\Console\Commands\SeedCommand; |
11
|
|
|
use Illuminate\Database\Eloquent\Relations\Relation; |
12
|
|
|
use Cortex\Statistics\Console\Commands\InstallCommand; |
13
|
|
|
use Cortex\Statistics\Console\Commands\MigrateCommand; |
14
|
|
|
use Cortex\Statistics\Console\Commands\PublishCommand; |
15
|
|
|
use Cortex\Statistics\Console\Commands\RollbackCommand; |
16
|
|
|
|
17
|
|
|
class StatisticsServiceProvider extends ServiceProvider |
18
|
|
|
{ |
19
|
|
|
use ConsoleTools; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The commands to be registered. |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
protected $commands = [ |
27
|
|
|
SeedCommand::class => 'command.cortex.statistics.seed', |
28
|
|
|
InstallCommand::class => 'command.cortex.statistics.install', |
29
|
|
|
MigrateCommand::class => 'command.cortex.statistics.migrate', |
30
|
|
|
PublishCommand::class => 'command.cortex.statistics.publish', |
31
|
|
|
RollbackCommand::class => 'command.cortex.statistics.rollback', |
32
|
|
|
]; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Register any application services. |
36
|
|
|
* |
37
|
|
|
* This service provider is a great spot to register your various container |
38
|
|
|
* bindings with the application. As you can see, we are registering our |
39
|
|
|
* "Registrar" implementation here. You can add your own bindings too! |
40
|
|
|
* |
41
|
|
|
* @return void |
42
|
|
|
*/ |
43
|
|
|
public function register(): void |
44
|
|
|
{ |
45
|
|
|
// Register console commands |
46
|
|
|
! $this->app->runningInConsole() || $this->registerCommands(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Bootstrap any application services. |
51
|
|
|
* |
52
|
|
|
* @return void |
53
|
|
|
*/ |
54
|
|
|
public function boot(Router $router): void |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
// Map relations |
57
|
|
|
Relation::morphMap([ |
58
|
|
|
'path' => config('rinvex.statistics.models.path'), |
59
|
|
|
'agent' => config('rinvex.statistics.models.agent'), |
60
|
|
|
'geoip' => config('rinvex.statistics.models.geoip'), |
61
|
|
|
'route' => config('rinvex.statistics.models.route'), |
62
|
|
|
'device' => config('rinvex.statistics.models.device'), |
63
|
|
|
'request' => config('rinvex.statistics.models.request'), |
64
|
|
|
'platform' => config('rinvex.statistics.models.platform'), |
65
|
|
|
]); |
66
|
|
|
|
67
|
|
|
// Load resources |
68
|
|
|
$this->loadRoutesFrom(__DIR__.'/../../routes/web/adminarea.php'); |
69
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../../resources/lang', 'cortex/statistics'); |
70
|
|
|
$this->app->runningInConsole() || $this->app->afterResolving('blade.compiler', function () { |
71
|
|
|
$accessarea = $this->app['request']->route('accessarea'); |
72
|
|
|
! file_exists($menus = __DIR__."/../../routes/menus/{$accessarea}.php") || require $menus; |
73
|
|
|
! file_exists($breadcrumbs = __DIR__."/../../routes/breadcrumbs/{$accessarea}.php") || require $breadcrumbs; |
74
|
|
|
}); |
75
|
|
|
|
76
|
|
|
// Publish Resources |
77
|
|
|
! $this->app->runningInConsole() || $this->publishesLang('cortex/statistics', true); |
78
|
|
|
! $this->app->runningInConsole() || $this->publishesMigrations('cortex/statistics', true); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.