2019-02-21 15:20:03 +00:00
|
|
|
<?php
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
|
|
use Closure;
|
2019-11-16 07:21:14 +00:00
|
|
|
use Illuminate\Support\Str;
|
2019-02-21 15:20:03 +00:00
|
|
|
|
|
|
|
|
class RedirectIfWizardCompleted
|
|
|
|
|
{
|
2019-12-11 20:29:35 +00:00
|
|
|
|
2019-02-21 15:20:03 +00:00
|
|
|
/**
|
|
|
|
|
* Handle an incoming request.
|
|
|
|
|
*
|
2019-12-11 20:29:35 +00:00
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
|
* @param \Closure $next
|
2019-02-21 15:20:03 +00:00
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
|
{
|
2019-12-11 20:29:35 +00:00
|
|
|
// Check wizard is completed or not
|
|
|
|
|
if (setting('wizard.completed', 0) == 1) {
|
2019-02-21 15:20:03 +00:00
|
|
|
return $next($request);
|
|
|
|
|
}
|
2019-12-11 20:29:35 +00:00
|
|
|
|
|
|
|
|
// Already in the wizard
|
|
|
|
|
if (Str::startsWith($request->getPathInfo(), '/wizard')) {
|
2019-02-21 15:20:03 +00:00
|
|
|
return $next($request);
|
|
|
|
|
}
|
2019-12-11 20:29:35 +00:00
|
|
|
|
|
|
|
|
// Not wizard completed, redirect to wizard
|
|
|
|
|
redirect()->route('wizard.edit')->send();
|
2019-02-21 15:20:03 +00:00
|
|
|
}
|
|
|
|
|
}
|