如何在别名表中赋予别名hasMany关系。
控制器
$templates = UserMaster::where ( 'INACTIVE', '=', 0 )->with('contact')->get ();
模型
public function contact(){
return $this->hasMany(\App\Models\Contact::class,'CONTACT_ID');
}
我可以尝试使用此代码,但会出错
$templates = UserMaster::where ( 'INACTIVE', '=', 0 )->with('contact as CONTACT')->get ();
那么如何在查询中使用别名?
谢谢