lumen5.8中雄辩的栏别名

时间:2019-09-12 05:31:31

标签: laravel-5 eloquent lumen

如何在别名表中赋予别名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 ();

那么如何在查询中使用别名?

谢谢

0 个答案:

没有答案