【发布时间】:2018-12-04 04:03:48
【问题描述】:
我有 5 个具有相同 client_id 的数据库行,3 个标记为 completed, Yes。
此代码按预期提取 3 个结果:
$indGoal = $client->indGoal()->where('completed','=','Yes')->get();
这段代码没有结果:我希望是 2。
$indGoal = $client->indGoal()->where('completed','!=','Yes')->get();
This question 建议添加 ->orWhereNull('completed') - 这有效,但忽略了 client_id 关系。请求带来所有非Yes 的结果,不管$client
我的客户模型供参考:
public function indGoal()
{
return $this->hasMany('App\Models\IndGoal');
}
【问题讨论】: