mercredi 11 septembre 2019

Eloquent column alias in lumen5.8

How to give alias in replated table hasMany relationship.

Controller

$templates = UserMaster::where ( 'INACTIVE', '=', 0 )->with('contact')->get ();

Model

public function contact(){
    return $this->hasMany(\App\Models\Contact::class,'CONTACT_ID');
}

I can try this code my but give error

$templates = UserMaster::where ( 'INACTIVE', '=', 0 )->with('contact as CONTACT')->get ();

So how give alias in with query?

Thank you



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/31dyymY
via IFTTT

Aucun commentaire:

Enregistrer un commentaire