2026-01-22 23:38:00 +01:00
|
|
|
<?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
|
|
|
|
|
{
|
2026-03-08 14:17:55 +01:00
|
|
|
if (! $this->onboardingService->needsOnboarding()) {
|
2026-01-22 23:38:00 +01:00
|
|
|
return redirect()->route('dashboard');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
|
}
|
2026-03-08 14:17:55 +01:00
|
|
|
}
|