title: Passing username to the url Laravel 5.2
body: <p>So I decided to change the look of the urls in my application. The current look is something like that: <code>/user/profile</code>. This is the page the user sees, after he's logged in.</p>
  
  <p>I want to pass the <code>$username</code> to the url, something like this: <code>/name_of_the_user/profile</code></p>
  
  <p>This is what I tried so far:</p>
  
  <p>Route:</p>
  
  <pre><code>Route::get('/{user}/profile', [
  'uses' =&gt;'UserController@getProfile',
  'as' =&gt; 'user.profile',
  'middleware' =&gt; 'auth'
  ]);
  </code></pre>
  
  <p>Link:</p>
  
  <pre><code>&lt;a href="{{ route('user.profile',auth()-&gt;check() ? auth()-&gt;user()-&gt;username : 'default') }}"&gt;User Profile&lt;/a&gt;
  </code></pre>
  
  <p>This is partially working.</p>
  
  <p>When the user logs in, he gets this error:</p>
  
  <blockquote>
    <p>UrlGenerationException in UrlGenerationException.php line 17:
    Missing required parameters for [Route: user.profile] [URI: {user}/profile].</p>
  </blockquote>
  
  <p>But if I reload the page its ok. The username passed successfully to the url as it supposed to. </p>
  
  <p>How can I fix this error? </p>
  
  <p>I should say that a user goes to <code>/user/signin</code> to sign in and he is being redirected to <code>/user/profile</code></p>
  
  <p>Any help is appreciated!</p>