|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Turahe\LaravelInstaller\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Routing\Router; |
|
6
|
|
|
use Illuminate\Support\ServiceProvider; |
|
7
|
|
|
use Turahe\LaravelInstaller\Middleware\canUpdate; |
|
8
|
|
|
use Turahe\LaravelInstaller\Middleware\canInstall; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class LaravelInstallerServiceProvider. |
|
12
|
|
|
*/ |
|
13
|
|
|
class LaravelInstallerServiceProvider extends ServiceProvider |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* Indicates if loading of the provider is deferred. |
|
17
|
|
|
* |
|
18
|
|
|
* @var bool |
|
19
|
|
|
*/ |
|
20
|
|
|
protected bool $defer = false; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Register the service provider. |
|
24
|
|
|
* |
|
25
|
|
|
* @return void |
|
26
|
|
|
*/ |
|
27
|
|
|
public function register() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->publishFiles(); |
|
30
|
|
|
$this->loadRoutesFrom(__DIR__.'/../Routes/web.php'); |
|
31
|
|
|
$this->mergeConfigFrom(__DIR__.'/../Config/installer.php', 'installer'); |
|
32
|
|
|
// $this->mapWebRoutes(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Bootstrap the application events. |
|
37
|
|
|
* |
|
38
|
|
|
* @param \Illuminate\Routing\Router $router |
|
39
|
|
|
*/ |
|
40
|
|
|
public function boot(Router $router) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->loadViewsFrom(__DIR__.'/Views', 'installer'); |
|
43
|
|
|
$router->middlewareGroup('install', [CanInstall::class]); |
|
44
|
|
|
$router->middlewareGroup('update', [CanUpdate::class]); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Publish config file for the installer. |
|
49
|
|
|
* |
|
50
|
|
|
* @return void |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function publishFiles() |
|
53
|
|
|
{ |
|
54
|
|
|
if (function_exists('config_path')) { // function not available and 'publish' not relevant in Lumen |
|
55
|
|
|
$this->publishes([ |
|
56
|
|
|
__DIR__.'/../Config/installer.php' => base_path('config/installer.php'), |
|
57
|
|
|
], 'laravelinstaller'); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$this->publishes([ |
|
61
|
|
|
__DIR__.'/../assets' => public_path('installer'), |
|
62
|
|
|
], 'laravelinstaller'); |
|
63
|
|
|
|
|
64
|
|
|
$this->publishes([ |
|
65
|
|
|
__DIR__.'/../Views' => base_path('resources/views/vendor/installer'), |
|
66
|
|
|
], 'laravelinstaller'); |
|
67
|
|
|
|
|
68
|
|
|
$this->publishes([ |
|
69
|
|
|
__DIR__.'/../Lang' => base_path('resources/lang'), |
|
70
|
|
|
], 'laravelinstaller'); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|