Reputation: 487
---------- tables ----------
users
customers
schedules
mails
--------- models ----------
schedules_model
public function customer()
{
return $this->belongsTo('App\Customer', 'customer_id');
}
public function mail()
{
return $this->belongsTo('App\Mail', 'mail_id');
}
public function user()
{
return $this->hasOneThrough(?);
}
--------- controllers ----------
$schedules = schedules_model->with('customer')->with('mail')->get();
Please help me how to get user information through customer ? Many thanks for your support!
Upvotes: 2
Views: 28
Reputation: 17205
Why getting the user information from the schedule directly, you can simply do
$schedules = schedules_model->with('customer.user')->with('mail')->get();
Upvotes: 1