Gets the rating to show stars on front end
<?php
/*
* PARAMS
* $number_of_stars (e.g 5)
* - number of stars to be shown
* $rating (e.g 3.2 )
* -rating score
* $max (e.g 5 )
* -maximum rating score
*/
$percentage = ($rating / $max * 100 );
$fullstars = round( $percentage / ( 100 / $number_of_stars) ) ;
$emptystars = $number_of_stars - $fullstars;
?>
<span class="rating__item rating__score">
@for( $i=0; $i<$fullstars; $i++ )
<i class="fas fa-star"></i>
@endfor
@for( $i=0; $i<$emptystars; $i++ )
<i class="far fa-star"></i>
@endfor
</span>