Laravel Issue : Call to a member function addEagerConstraints() on string in file C:\xampp\htdocs\F5_Venuu\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php
i am getting error:Call to a member function addEagerConstraints() on string in file C:\xampp\htdocs\F5_Venuu\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php
Venue.php
public function reviews()
{
return $this->hasMany(Rating::class);
}
public function avgrate()
{
return $this->reviews()->avg('rating');
}
Rating.php
public function venue()
{
return $this->belongsTo(Venue::class);
}
in my controller I am using
return Venue::with('avgrate')->get()
I want to get each Venue model entry with average rating.
Kindly Help.