Call to a member function addEagerConstraints() on string

I want to calculate the average of the column of nested morph relation.

Model Function

public function trader_ratings()
{
return $this->morphMany(TraderRatings::class, 'rateable')->select('rateable_id','rateable_type','rating')->avg('rating');
}

Controller with lazy loading

            $user = auth('api')->user();
$user_id = $user->id;
$customer_classes = CustomerClassBooking::with([
'trader_class',
'trader_class.trader_ratings'

,'vendor'])

->where('customer_id',$user_id)
->where('status','Accepted-paid')
->get();

It is not calculating the avg but giving the error



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2GmF5mt
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time