Notdavis
1558
5
Eloquent

Call to undefined method Illuminate\\Database\\Query\\Builder but Method Exists

Posted 1 year ago by Notdavis

I can't figure out what I am missing, but I'm sure it will be something very obvious.

Models:

class User extends Authenticatable
{

    public function claims()
    {
        return $this->hasMany('App\Models\Claim');
    }
}

class Claim extends Model
{
    // user_id on table
    public function user()
    {
            return $this->belongsTo('App\Models\User');
    }
    public function submittedClaim()
    {
        return $this->hasOne('App\Models\SubmittedClaim');
    }
}

class SubmittedClaim extends Model
{
    // claim_id on table
    public function Claim()
    {
        return $this->belongsTo('App\Models\Claim');
    }
}

Code:

$user = Auth::user();
$user->claims()->submittedClaim()->where('update', '=', 1)->get();

Error:

Call to undefined method Illuminate\Database\Query\Builder::submittedClaim()

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