|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PolarAdmin\Polar; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Routing\Router; |
|
6
|
|
|
use Illuminate\Support\ServiceProvider; |
|
7
|
|
|
use PolarAdmin\Polar\Http\Middleware\PolarAdminMiddleware; |
|
8
|
|
|
|
|
9
|
|
|
class PolarServiceProvider extends ServiceProvider |
|
10
|
|
|
{ |
|
11
|
|
|
public function boot(Router $router) |
|
12
|
|
|
{ |
|
13
|
|
|
if ($this->app->runningInConsole()) { |
|
14
|
|
|
$this->publishes([ |
|
15
|
|
|
__DIR__.'/../config/polar.php' => config_path('polar.php'), |
|
16
|
|
|
], 'config'); |
|
17
|
|
|
|
|
18
|
|
|
$this->publishes([ |
|
19
|
|
|
__DIR__.'/../resources/views' => base_path('resources/views/vendor/polar'), |
|
20
|
|
|
], 'views'); |
|
21
|
|
|
|
|
22
|
|
|
$this->publishes([ |
|
23
|
|
|
__DIR__.'/../resources/assets' => public_path('vendor/polar'), |
|
24
|
|
|
], 'public'); |
|
25
|
|
|
|
|
26
|
|
|
$this->publishes([ |
|
27
|
|
|
__DIR__.'/../resources/lang' => resource_path('lang/vendor/polar'), |
|
28
|
|
|
]); |
|
29
|
|
|
|
|
30
|
|
|
$this->publishesMigrations(); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
$router->aliasMiddleware('polar-admin', PolarAdminMiddleware::class); |
|
34
|
|
|
|
|
35
|
|
|
$this->loadRoutesFrom(__DIR__.'/../routes/api.php'); |
|
36
|
|
|
$this->loadRoutesFrom(__DIR__.'/../routes/web.php'); |
|
37
|
|
|
|
|
38
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'polar'); |
|
39
|
|
|
|
|
40
|
|
|
$this->loadViewsFrom(__DIR__.'/../resources/views', 'polar'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function register() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->mergeConfigFrom(__DIR__.'/../config/polar.php', 'polar'); |
|
46
|
|
|
|
|
47
|
|
|
$this->app->alias(Polar::class, 'polar-admin'); |
|
48
|
|
|
|
|
49
|
|
|
$this->registerServices(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
protected function publishesMigrations() |
|
53
|
|
|
{ |
|
54
|
|
|
$migrations = array_slice(scandir(__DIR__.'/../database/migrations'), 2); |
|
55
|
|
|
|
|
56
|
|
|
foreach ($migrations as $migration) { |
|
57
|
|
|
if (!class_exists(studly_case(substr($migration, 0, -4)))) { |
|
58
|
|
|
$timestamp = date('Y_m_d_His', time()); |
|
59
|
|
|
$this->publishes([ |
|
60
|
|
|
__DIR__.'/../database/migrations/'.$migration => database_path("migrations/{$timestamp}_{$migration}"), |
|
61
|
|
|
], 'migrations'); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
protected function registerServices() |
|
67
|
|
|
{ |
|
68
|
|
|
$services = [ |
|
69
|
|
|
'Repositories\PolarNotificationRepository', |
|
70
|
|
|
]; |
|
71
|
|
|
|
|
72
|
|
|
foreach ($services as $service) { |
|
73
|
|
|
$this->app->singleton('PolarAdmin\Polar\Contracts\\'.$service, 'PolarAdmin\Polar\\'.$service); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|