2
The code below works, but I wanted to know how to do it all query, and if the way I’m riding her is really the best way.
$query = Avaliar::select(DB::raw('COUNT(id) as contar'), DB::raw('SUM(nota) as total'))
->where('serie_id', $serie->id)
->first();
$nota = $query->total / $query->contar;