UserModel has many lead and each lead can have one propertyLead and each propertyLead can have many attachments. Each model is listed below,
UserModel:
public function leads() { return $this->hasMany('App\Models\Leads', 'fk_user_id'); }
LeadsModel:
public function propertyLead() { return $this->hasOne('App\Models\PropertyLead', 'fk_lead_id'); }
PropertyLeadModel:
public function attachments() { return $this->hasMany('App\Models\Attachments', 'fk_property_lead_id'); }
Now, I am using the Lazy Eager Loading of laravel to readData from dataBase, so far I am able to reach to PropertyLeadModel but I am not able to understand how to reach to attachment relation in the PropertyLeadModel,
$leads = User::find(Auth::user()->id)->leads->load('propertyLead');
so user gives me leads and leads gives me propertyLead but not able to understand how to reach more down to Attachments in the propertyLeadModel.
Please, help me to understand. Thank you.
from Recent Questions - Stack Overflow https://stackoverflow.com/questions/65376488/lazy-eager-loading-for-third-level-relationship-in-laravel Mohsin Younas http://ifttt.com/images/no_image_card.png
没有评论:
发表评论