29 lines
No EOL
657 B
PHP
29 lines
No EOL
657 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Services\OnboardingService;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class RedirectIfOnboardingComplete
|
|
{
|
|
public function __construct(
|
|
private OnboardingService $onboardingService
|
|
) {}
|
|
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* Redirect to dashboard if onboarding is already complete.
|
|
*/
|
|
public function handle(Request $request, Closure $next): Response
|
|
{
|
|
if (!$this->onboardingService->needsOnboarding()) {
|
|
return redirect()->route('dashboard');
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
} |