2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
2016-05-14 16:09:00 -07:00
|
|
|
use App\Models\Setting;
|
2019-03-13 20:12:03 -07:00
|
|
|
use Closure;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
class CheckForSetup
|
|
|
|
{
|
2024-10-02 07:36:01 -07:00
|
|
|
|
|
|
|
protected $except = [
|
|
|
|
'_debugbar*',
|
|
|
|
'health'
|
|
|
|
];
|
|
|
|
|
2016-03-25 01:18:05 -07:00
|
|
|
public function handle($request, Closure $next, $guard = null)
|
|
|
|
{
|
|
|
|
|
2018-11-01 19:59:50 -07:00
|
|
|
/**
|
2024-10-02 07:36:01 -07:00
|
|
|
* Skip this middleware for the debugbar and health check
|
2018-11-01 19:59:50 -07:00
|
|
|
*/
|
2024-10-02 07:36:01 -07:00
|
|
|
if ($request->is($this->except)) {
|
2016-11-29 01:19:05 -08:00
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
|
2016-06-22 12:27:41 -07:00
|
|
|
if (Setting::setupCompleted()) {
|
|
|
|
if ($request->is('setup*')) {
|
2023-04-05 16:05:40 -07:00
|
|
|
return redirect(config('app.url'));
|
2016-05-14 16:09:00 -07:00
|
|
|
} else {
|
|
|
|
return $next($request);
|
2016-06-22 12:27:41 -07:00
|
|
|
}
|
|
|
|
} else {
|
2024-10-02 07:36:01 -07:00
|
|
|
if (! ($request->is('setup*')) && ! ($request->is('.env'))) {
|
2023-04-05 16:05:40 -07:00
|
|
|
return redirect(config('app.url').'/setup');
|
2016-05-14 16:09:00 -07:00
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
|
2016-06-22 12:27:41 -07:00
|
|
|
return $next($request);
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|
|
|
|
}
|