57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware\Installer;
|
|
|
|
use Closure;
|
|
|
|
class canInstall
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return \Illuminate\Http\RedirectResponse|mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
dd($this->alreadyInstalled());
|
|
if ($this->alreadyInstalled()) {
|
|
$installedRedirect = config('installer.installedAlreadyAction');
|
|
|
|
switch ($installedRedirect) {
|
|
case 'route':
|
|
$routeName = config('installer.installed.redirectOptions.route.name');
|
|
$data = config('installer.installed.redirectOptions.route.message');
|
|
return redirect()->route($routeName)->with(['data' => $data]);
|
|
break;
|
|
case 'abort':
|
|
abort(config('installer.installed.redirectOptions.abort.type'));
|
|
break;
|
|
|
|
case 'dump':
|
|
$dump = config('installer.installed.redirectOptions.dump.data');
|
|
break;
|
|
|
|
case '404':
|
|
case 'default':
|
|
default:
|
|
abort(404);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
|
|
/**
|
|
* If application is already installed.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function alreadyInstalled()
|
|
{
|
|
return file_exists(storage_path('installed'));
|
|
}
|
|
}
|