title: laravel 5.2 how to pass variable to route.php from middleware?
body: <p>i have a middleware, i want it to pass $role to the route.php</p>
  
  <pre><code>public function handle($request, Closure $next)
  {
      if ($this-&gt;auth-&gt;check())
      {
  
          $role= "normal";
          $user_roles = AssignedRoles::join('roles','role_user.role_id','=','roles.id')
          -&gt;where('user_id', $this-&gt;auth-&gt;user()-&gt;id)-&gt;select('roles.is_admin', 'roles.is_vendor')-&gt;get();
          foreach($user_roles as $item)
          {
              //var_dump($item-&gt;is_vendor);
              //die();
              if($item-&gt;is_admin==1)
              {
                  $role = "admin";
              }
              if($item-&gt;is_vendor==1)
              {
                  $role = "vendor";
              }
          }
          if($role=="normal"){
              return $this-&gt;response-&gt;redirectTo('/');
          }
          //$request-&gt;attributes-&gt;add(['admin' =&gt; $admin, 'vendor' =&gt; $vendor]);
          $request-&gt;attributes-&gt;add(['role' =&gt; $role]);
          View::share ('role', $role);
  
          return $next($request);
      }
      return $this-&gt;response-&gt;redirectTo('/');
  }
  </code></pre>
  
  <p>is there any way to do that?</p>
  
  <p>My route:</p>
  
  <pre><code>Route::group(['prefix' =&gt; 'admin', 'middleware' =&gt; ['auth']], function() {
      Route::auth();
      Route::pattern('id', '[0-9]+');
      Route::pattern('id2', '[0-9]+');
  
      #Admin Dashboard
      Route::get('dashboard', 'Admin\DashboardController@index');
  
      Route::get('vendor/{id}/edit', 'Admin\VendorController@getEdit');
      Route::post('vendor/{id}/edit', 'Admin\VendorController@postEdit'); 
  
  });
  </code></pre>