laravel/framework — pull request #3221 by loon88 (2014-01-13 22:26:46+00:00)
Title: Using scope parameter with eager loading constraints

In the eager loading part

$name = 'justmyname';
$user = User::with(array('specials' => function($query)
{
$query->special($name);
}))->where('users.id', $userId)->get();

and in my scope (in model)

public function scopeSpecial($query, $name)
{
return $query->whereRaw('special_name = ' . $name);
}

All of this works perfectly. until i use them with eager loading. i got error message saying
Undefined variable: name

can see that laravel cannot find the variable. $name
scope doesn't work in eager loading? or is there any extra parameter i need to pass in to get this works?