Redirect to profile page after authentication in laravel
<p>When a user logs in I want them to be redirected to their profile page instead of homepage. I have a method in another controller that gets a user profile. Not sure what I need to do since the user profile takes a username variable but when user logs in I'm only asking for email and password. </p>

<p>My route file, but the following method is in a different controller from the authentication controller.</p>

<pre><code>Route::get('/user/{username}', [
    'uses' =&gt; 'ProfileController@getProfile',
    'as' =&gt; 'profile.index',
    'middleware' =&gt; ['auth'],
    ]);
</code></pre>

<p>My following method is in my authentication controller.</p>

<pre><code>public function postSignin(Request $request)
{
    $this-&gt;validate($request, [
        'email' =&gt; 'required',
        'password' =&gt; 'required',

        ]);

    if (!Auth::attempt($request-&gt;only(['email', 'password']),      $request-&gt;has('remember'))) {
        return redirect()-&gt;back()-&gt;with('info' , 'Could not sign you in with that info.');
    }

        $user= User::where('username', $username)-&gt;first();
        return redirect()-&gt;route('profile.index')
        -&gt;with('info', 'You are now signed in.')
        -&gt;with('user', $user);
     }
</code></pre>

<p>The following is in my profile controller..</p>

<pre><code>public function getProfile($username)
{
    $user= User::where('username', $username)-&gt;first();

    if (!$user){
        abort(404);
    }
    return view('profile.index')
        -&gt;with('user', $user);
}
</code></pre>