dimanche 18 octobre 2015

Laravel 5 customizing built in login redirect

I am customizing laravel 5's built in login so that it would redirect to three different paths according to the type column which i added to the users table, i tried altering the handle function of RedirectIfAuthenticated middleware. but it seems that it always finds the home URI.

here is my edited middleware

public function handle($request, Closure $next)
    {
        if ($this->auth->check() && $this->auth->user()->type == 'patient') {
            // return redirect('/home');
            return 'PATIENT VIEW';
        } elseif ($this->auth->check() && $this->auth->user()->type == 'doctor') {

            return 'DOCTOR VIEW';

        } elseif ($this->auth->check() && $this->auth->user()->type == 'nurse') {

            return 'NURSE VIEW';
        }

        return $next($request);
    }

Im new to laravel 5 and i would really appreciate any help and explanations



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire