【发布时间】:2020-10-15 17:26:04
【问题描述】:
是否有任何过滤员工和人力表记录的方法也不返回?
$result = Pwra::with('purchaseOrder', 'manpower')
->where('pwra_dt', $date)
->where('time_session', $session)
->whereHas('manpower.employees', function ($q) {
$q->where('status', 1);
})
->get();
Pwra 类
public function manpower()
{
return $this->hasMany('App\Models\Manpower', 'pwra_uuid', 'pwra_uuid');
}
人力类
public function employee()
{
return $this->hasOne('App\Models\Employees', 'employees_uuid', 'employees_uuid')->where('status', 1);
}
我的预期是:当员工Status = 0时,它不会返回任何记录,甚至人力。
【问题讨论】:
-
我已经尝试过,但仍然不适合我
-
我认为你需要做 2 次
whereHas或join -
嗯...任何例子 2 次
whereHas? -
它不起作用
with('manpower.employees')
标签: laravel