laravel/framework — pull request #1801 by rmasters (2013-07-02 14:30:13+00:00)
Title: Add method of getting route parameter without evaluating all params

PR for #1787

I wanted to be able to load a model instance in the binder of another method - for example, the binder below will pass (Author, Post) to the actions of a number of routes. The problem (as in the issue) is that `$route->getParameter()` evaluates all the route variables, including this binder (so you end up with an infinite loop). `getSingleParameter` resolves just this variable.

Route::bind('post', function ($value, $route) {
$client = $route->getSingleParameter('author');
if ($author) {
return Post::where('id', '=', $value)->where('author_id', '=', $author->id)->first();
} else {
// Chuck a 404 here
}
});

I'm not 100% sure this is the wisest design choice but it saves me some code across controllers - let me know if this is silly :)