Hello. I have models and tables Complex, Floors with the following structures:
complex - complex_id, number, descriptiom floors - floor_id, complex_id, number, description
In the Complex model, I make a one-to-many connection (one complex can have several floors):
public function floors(){ return $this->hasMany('App\Floors', 'complex_id'); } In the Floors model, I do the opposite relationship:
public function complex(){ return $this->belongsTo('App\Complex', 'complex_id'); } Trying to get all the floors of the first complex:
Complex::first()->floors(); The result is empty. What could be wrong?
Complex::first()->floors? - Zippbl4