Uzyskaj ocenę procentową w Laravel
$ratings = Rating::select('rating', DB::raw('count(id) as count'))
->groupBy('rating')
->get();
Sleepy Sardine
$ratings = Rating::select('rating', DB::raw('count(id) as count'))
->groupBy('rating')
->get();
@foreach($ratings as $rating)
Percentage: {{ ($rating->count / 100) * $total); }}
@endforeach
$total =$ratings->sum('count');