4 months ago

Call to a member function addEagerConstraints() on integer with scope function

Posted 4 months ago by jorisvanandel

One of my models has a relationship with another model and I want to put the sum of one of it's values in a scope so I can call it conditionally.

Right now I have the following code.

public function scopeWithSum ($query)
    return $query->with('relationship')->sum('column');

It gives the error in the title. Amy help is appreciated.

Please sign in or create an account to participate in this conversation.