0
我是PHP新手。如何将范围变量传递给匿名函数
我想创建一个函数链接这个。
public static function cat_post($category, $limit, $top)
{
$posts = Post::whereHas('categories', function($q)
{
$q->where('name', 'like', $name);
$q->where('top', 'like', $top);
})->take($limit)->get();
}
,但我得到
Undefined variable "name"
请帮助我。如何创建这个功能....