Skip to content

Instantly share code, notes, and snippets.

@Partoo
Created July 28, 2015 03:28
Show Gist options
  • Select an option

  • Save Partoo/0fec7d482c3d7f085547 to your computer and use it in GitHub Desktop.

Select an option

Save Partoo/0fec7d482c3d7f085547 to your computer and use it in GitHub Desktop.
Route::group(array('prefix' => 'api'), function()
{
Route::resource('cities', 'CitiesAPIController');
});
Route::filter('manage-city', function(){
if (! Entrust::can('edit-city') && $_SERVER['REQUEST_METHOD']!='GET') // Checks the current user
{
$API= new Twiddle\Http\Controllers\ApiController();
return $API->noPermissions('User Unauthorized','You are not allowed to view cities');
}
});
Route::when('api/cities*', 'manage-city');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment