title: laravel route filter to check user roles
body: <p>I am building a restful api in laravel 4 where there are users with different types of permission.  I want to restrict access to different routes depending on the user role (which is saved in the user table in db)</p>
  
  <p>How would I do that?  Here is what I have so far (it's not working so far).  </p>
  
  <p>filters.php </p>
  
  <pre><code>//allows backend api access depending on the user's role once they are logged in
  Route::filter('role', function()
  { 
  return Auth::user()-&gt;role;
  }); 
  </code></pre>
  
  <p>routes.php</p>
  
  <pre><code> Route::group(array('before' =&gt; 'role'), function($role) {
   if($role==1){
          Route::get('customer/retrieve/{id}', 'CustomerController@retrieve_single');
          Route::post('customer/create', 'CustomerController@create');
          Route::put('customer/update/{id}', 'CustomerController@update');
   }
  
      });
  </code></pre>
  
  <p>Is it possible that I'm writing the syntax wrong for a "group filter"?</p>