Forked from jeffersongoncalves/CheckUserCompleteInfo.php
Created
February 10, 2025 14:25
-
-
Save cpereiraweb/816560cd68a65ede56ec65e8a5e179db to your computer and use it in GitHub Desktop.
Middleware check user info completed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
class CheckUserCompletedInfo | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param Closure(Request): (Response) $next | |
*/ | |
public function handle(Request $request, Closure $next): Response | |
{ | |
if (auth()->user()->completed) { | |
return redirect()->route('dashboard'); | |
} | |
return $next($request); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
class CheckUserCompleteInfo | |
{ | |
/** | |
* Handle an incoming request. | |
* | |
* @param Closure(Request): (Response) $next | |
*/ | |
public function handle(Request $request, Closure $next): Response | |
{ | |
if (! auth()->user()->completed) { | |
return redirect()->route('first-access'); | |
} | |
return $next($request); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::middleware('auth') | |
->group(function () { | |
Route::get('/primeiro-acesso', Platform\FirstAccessController::class) | |
->middleware(CheckUserCompletedInfo::class) | |
->name('first-access') | |
->withoutScopedBindings(); | |
Route::middleware(CheckUserCompleteInfo::class) | |
->group(function () { | |
// Rotas protegidas | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment