samedi 26 décembre 2015

Laravel eagerload a custom query instead of relationship

I have a query that I want to eager load but its not working.

I have previously eager loaded relationships and its worked fine but this keeps giving me this error:

Call to a member function addEagerConstraints() on null

My function in the model:

public function update_image()
{
    return UpdateItem::where('type', 'image')->where('update_id', $this->id)->first();
}

And its called:

$updates = Update::with('project', 'update_items', 'update_image')->get();

I know the query itself is fine, but where is this going wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire