Php Laravel,其中还返回空结果
我使用Laravel 4来获取对某个事件有分数的所有人 这就是我正在使用的查询Php Laravel,其中还返回空结果,php,laravel,eloquent,Php,Laravel,Eloquent,我使用Laravel 4来获取对某个事件有分数的所有人 这就是我正在使用的查询 $event = Person::with(array('eventscore' => function($q){ $q->where('id', 3); }))->get(); 问题是它还返回eventscore表中没有分数的人。 这是输出 有没有办法让我只返回有分数的人? 谢谢 with()不会限制返回的人员,它只会限制事件分数。如果您只需要具有事件分数的人员s,可以使用has或wh
$event = Person::with(array('eventscore' => function($q){
$q->where('id', 3);
}))->get();
问题是它还返回eventscore表中没有分数的人。
这是输出
有没有办法让我只返回有分数的人?
谢谢 with()
不会限制返回的人员,它只会限制事件分数。如果您只需要具有事件分数的人员
s,可以使用has
或whereHas
$event = Person::whereHas('eventscore', function($q) {
$q->where('id', 3);
})->get();
完美的多谢各位