0
votes

https://laravel.com/docs/5.3/authentication#authentication-quickstart

It says

If the redirect path needs custom generation logic you may define a redirectTo method instead of a redirectTo property

but I add a redirectTo method in my LoginController, it not working!!

Still redirect to '/home' !!!

    <?php

namespace App\Http\Controllers\Mass\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
//    protected $redirectTo = '/home';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);
    }

//    public function index()
//    {
//        return \Auth::user();
//    }

    protected function redirectTo()
    {
        //
        die(var_dump(1));
    }
}
1
could you show us the code?manix

1 Answers

0
votes

same thing happens to me here's my code

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Log;


class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;


    protected $redirectTo = '/myaccount';


    public function __construct()
    {
        $this->middleware('guest', ['except' => 'logout']);


    }

    protected function redirectTo()
    {
         Log::info('redirecthere');
    }

}