2019-02-21 18:20:03 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
2019-11-16 10:21:14 +03:00
|
|
|
use Illuminate\Support\Str;
|
2019-02-21 18:20:03 +03:00
|
|
|
|
|
|
|
class RedirectIfWizardCompleted
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
// Not in wizard
|
2019-11-16 10:21:14 +03:00
|
|
|
if (!Str::startsWith($request->getPathInfo(), '/wizard')) {
|
2019-02-21 18:20:03 +03:00
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wizard not completed
|
2019-11-16 10:21:14 +03:00
|
|
|
if (!setting('wizard.completed', 0)) {
|
2019-02-21 18:20:03 +03:00
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wizard completed, redirect to home
|
|
|
|
redirect()->intended('/')->send();
|
|
|
|
}
|
|
|
|
}
|