laravel/framework — pull request #6414 by IonutBajescu (2014-11-15 16:06:00+00:00)
Title: added callable wheres on route

Example of usage:
```php
$router
->get('/{page}', function(){
return 'a page';
})
->where(function($route, $request){
$slugs = ['about', 'tos'];
return in_array($route->page, $slugs);
});

$router
->get('/{post}', function(){
return 'a post';
})
->where(function($route, $request){
$slugs = ['hello-world'];
return in_array($route->post, $slugs);
});
```

A huge number of projects needs this feature. Before callable wheres we used some regex "hacks" with slugs separated by |, or a ugly foreach. Ex:
```php
$slugs = Page::lists('slug');
foreach($slugs as $slug){
Route::get('/'.$slug, function() use($slug){
return View::make('page')->with('slug', $slug);
});
}
```