Total Complexity | 7 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class CanUpdate |
||
14 | { |
||
15 | use MigrationsHelper; |
||
16 | |||
17 | /** |
||
18 | * Handle an incoming request. |
||
19 | * |
||
20 | * @param Request $request |
||
21 | * @param Closure $next |
||
22 | * @return mixed|RedirectResponse |
||
23 | */ |
||
24 | public function handle($request, Closure $next): RedirectResponse |
||
25 | { |
||
26 | $updateEnabled = filter_var(config('installer.updaterEnabled'), FILTER_VALIDATE_BOOLEAN); |
||
27 | switch ($updateEnabled) { |
||
28 | case true: |
||
29 | $canInstall = new canInstall; |
||
30 | |||
31 | // if the application has not been installed, |
||
32 | // redirect to the installer |
||
33 | if (! $canInstall->alreadyInstalled()) { |
||
34 | return redirect()->route('LaravelInstaller::welcome'); |
||
35 | } |
||
36 | |||
37 | if ($this->alreadyUpdated()) { |
||
38 | abort(404); |
||
39 | } |
||
40 | break; |
||
41 | |||
42 | case false: |
||
43 | default: |
||
44 | abort(404); |
||
45 | break; |
||
46 | } |
||
47 | |||
48 | return $next($request); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * If application is already updated. |
||
53 | * |
||
54 | * @return bool |
||
55 | */ |
||
56 | public function alreadyUpdated(): bool |
||
69 | } |
||
70 | } |
||
71 |