mercredi 18 août 2021

middleware not redirect to view

i have a problem with middleware

my middleware should redirect to a view if the logged in user has the column 'edad' = Null

User loggin DB: https://i.imgur.com/9UubPls.png

    <?php

namespace App\Http\Middleware;

use Auth;
use Closure;
use Illuminate\Http\Request;

class Personales
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (Auth::guest()) {
            return $next($request);
        }
        
        if ($request->route()->getName() == "completar" || $request->route()->getName() == "ucompletar") {
            return $next($request);
        }

        if (Auth::user() && Auth::user()->edad != null && Auth::user()->edad != "") {
            return $next($request);
        } else {
            return redirect('/completar');
        }
    }
}

i can't find the error because it doesn't work middleware

maybe i'm missing something, just create middleware and view



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3k9ZZc6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire