I am using a middleware in Laravel 5.4 and would like it if the logged in user had 2 permission to be redirected to / admin / inscripts. The scope of the handle method looks like this, but redirection does not work. Any ideas?
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class AdminMiddleware{
public function handle($request, Closure $next){
// SE O USUÁRIO NÃO ESTIVER LOGADO REDIRECIONA PARA O LOGIN
if (!Auth::check()) {
return redirect('login');
}else{
// SE O USUÁRIO QUE LOGOU FOR CANDIDATO REDIRECIONA PARA MINHA CONTA
if($request->user()->permissao !== 2){
return redirect('/minhaconta');
}elseif($request->user()->permissao === 2){
return redirect('/admin/inscricoes');
}else{
return $next($request);
}
}
}
}