title: set Default value for a route in laravel alongside a url param binding
body: <p>ok lets say i have a <code>ProfileController.php</code>.
  in the <code>edit</code> method it looks like this:</p>
  
  <pre><code>class ProfileController extends Controller
  {
      public function edit(\App\User $user)
      {
          return view('profile.edit',compact('user'));
      }
       public function update(\App\User $user, \App\Http\Requests\ProfileRequest $request)
       {
           $user-&gt;update($request-&gt;all());
           return back()-&gt;withStatus(__('Profile successfully updated.'));
       }
  }
  </code></pre>
  
  <p>it simply shows the user's profile and a form to edit it.</p>
  
  <p>the route to this method looks like this:</p>
  
  <pre><code>Route::group(['middleware' =&gt; 'auth'], function () {
      Route::group(['middleware' =&gt; '\App\Http\Middleware\DefaultUrlParamsMiddleware'], function () {
          Route::get('profile/{username?}', ['as' =&gt; 'profile.edit', 'uses' =&gt; 'ProfileController@edit']);
          Route::put('profile/{username?}', ['as' =&gt; 'profile.update', 'uses' =&gt; 'ProfileController@update']);
      });
  });
  </code></pre>
  
  <p>as you can see there is an optional <code>username</code> param in this url, and what i want is to bind this url param to a user object that is required for the <code>ProfileController.php</code> methods.</p>
  
  <p>for that I have this in my <code>appProvider.php</code>:</p>
  
  <pre><code>class AppServiceProvider extends ServiceProvider
  {
      public function register()
      {
          //
      }
  
      public function boot(Router $router)
      {   
          // provide user for profile edit
          $router-&gt;bind( 'username', function ( $username ){
              return \App\User::where( 'name', $username )-&gt;firstOrFail();
          });
      }
  }
  </code></pre>
  
  <p>at this moment everything works good BUT, only if I provide the <code>username</code> param in the url, for example if i go to <code>mydomain.test/profile/mytestinguser</code> it works good.</p>
  
  <p>WHAT I WANT IS IF I DONT PROVIDE THE USERNAME PARAM IN THE URL, IT SHOULD USE MY CURRENT USERNAME BY DEFAULT,
  so if i go to <code>mydomain.test/profile</code> it should consider the username param equal to my current username which is <code>mytestinguser</code> and then use the binding to parse it to a user object and then pass it to the <code>edit</code> method. but it does not work. so I looked up a little bit and there was something about URL::defaults in a middleware, so I setted this middleware called <code>DefaultUrlParamsMiddleware</code> and then its content is as follow:</p>
  
  <pre><code>use Illuminate\Support\Facades\URL;
  
  class DefaultUrlParamsMiddleware
  {
      public function handle($request, Closure $next)
      {
          URL::defaults(['username' =&gt;  auth()-&gt;user()-&gt;name ]);
  
          return $next($request);
      }
  }
  </code></pre>
  
  <p>but thats not working either and just shows me a null as <code>$user</code> in the <code>edit</code> method. why is that?</p>