I have a few belongsTo
relations in an app, with the 'lowest' child being an Element
. The models have the following functions:
// Element
public function field(){
return $this->belongsTo('Field');
}
// Field
public function section(){
return $this->belongsTo('Section');
}
// Section
public function form(){
return $this->belongsTo('Form');
}
How can I say something along the lines of:
$elements = Element::where('field.section.form.id', '=', 1);
And return all the elements that belong to the form with an ID of 1. Eager loading has served me well but I'm confused if there is a way of doing this.