获取不完全药物的患者数量和患者姓名,并提供用药细节。
我在我的PatientsController索引方法中尝试了这一点
$ontreatment = Patient::all()->medications->where('completed', false)->get();我的Patient.php有如下关系
public function medications()
{
return $this->hasMany('App\Medication');
}我的Medication.php模型有以下关系:
public function patients()
{
return $this->belongsTo('App\Patient');
}我的路线如下:
Route::get('/patients', 'PatientsController@index');不是的。患者没有完成他们的药物治疗和一个表与病人的名字和药物的细节(临床医生,治疗,treatmentDate.)如果治疗不完全。
发布于 2019-01-22 13:11:04
您可以约束您的medications关系如下:
$ontreatment = Patients::whereHas('medications', function($query) {
$query->where('completed', false);
})->get();这就是你要找的吗?
https://stackoverflow.com/questions/54305810
复制相似问题