Created
February 23, 2018 23:10
-
-
Save cvega93/d451421bb02d0d836c6765ccb9ebeba7 to your computer and use it in GitHub Desktop.
Loop rating stars with blade + Google Markup Microdata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//use Fontawesome | |
@for ($x = 1; $x <= $name->ratingAverage; $x++) | |
<i class="fa fa-star"></i> | |
@endfor | |
@if (strpos($name->ratingAverage, '.')) | |
<i class="fa fa-star-half-o"></i> | |
@php | |
$x++; | |
@endphp | |
@endif | |
@while ($x <= 5) | |
<i class="fa fa-star-o"></i> | |
@php | |
$x++; | |
@endphp | |
@endwhile | |
//Google Markup Microdata | |
<script type="application/ld+json"> | |
{ | |
"@context": "http://schema.org", | |
"@type": "Product", | |
"description": "{{$name->description}}", | |
"name": "{{$name->name}}", | |
"aggregateRating": { | |
"@type": "AggregateRating", | |
"ratingCount": "{{ $name->ratings->count() }}", | |
"ratingValue": "{{ $name->ratingAverage }}" | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment