Home LARAVEL ELOQUENT - I want to add column from user table to a relation table
Reply: 0

LARAVEL ELOQUENT - I want to add column from user table to a relation table

user996
1#
user996 Published in July 20, 2018, 2:22 pm

I am not much familiar with eloquent orm in laravel

I have 3 tables they are

 -- leads
       |
        Lead_appointments

   and users table

since lead_appointments belongs to leads references id on leads by lead_id

the leads_appointments has a column called created_by with user's id in it

I am trying to query user's name and email along with the result as another column when query using eloquent

Lead Model

  class Leads extends Model
     { 
        public function appointments()
        {
           return $this->hasMany('App\Models\LeadsAppointments', 'lead_id');
        }
     }

My eloquent query in controller

   return $this->lead->with('appointments')->find($id);

the result is like this

In under appointments i also want user email and name along with created by in it

But I couldn't figure it out

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312498 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO