Call to a member function addEagerConstraints() on a non-object

Viewed 12059

I get this error msg Call to a member function addEagerConstraints() on a non-object when I am trying to call a function from my model. Here is the function:

public static function checkClaimById($claim_id) {
    $result = Claim::with('orders')
        ->find($claim_id)
        ->where('orders.user_id', Auth::user()->id)
        ->whereNull('deleted_at')
        ->count();
    if($result >= 1) {
        return true;
    } else {
        return false;
    }
}

I have the Model "claim" with has a field order_id and it belongs to an order. And I have the model "order" and one Order has many claims.

Can someone help me?

thanks Regards

1 Answers
Related