https://laravel.com/docs/5.2/eloquent-relationships#eager-loading multiple relationships?
App\User::with('stories', 'photos')->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Im getting this error:
BadMethodCallException in Macroable.php line 81: Method addEagerConstraints does not exist.
In my User model im tryng to merge two relationships.
I have the same thing working on a different project but i can't figure out why here it isn't working.
public function stories()
{
return $this->hasMany('App\Models\Story')->where('published','=','1')->orderBy('order');
}
public function photos()
{
return $this->hasMany('App\Models\Photo')->where('published','=','1')->orderBy('order');
}
public function content()
{
return $this->stories->union($this->photos);
}
Version: Laravel 5.2.*
Does anyone had the same error o has any clue why it happens... i've been debugging for a while without any clues
Thanks in advance :)
Please or to participate in this conversation.