Skip to content

Commit

Permalink
Get count and score earlier from PHP instead of GraphQL (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
indykoning authored Feb 2, 2022
1 parent c49e9f9 commit 505d6b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Add the stars where you'd like in `resources/views/vendor/rapidez/product/overvi

The review list can be added with:
```
@include('rapidez-reviews::reviews', ['sku' => $product->sku])
@include('rapidez-reviews::reviews', ['sku' => $product->sku, 'reviews_count' => $product->reviews_count, 'reviews_score' => $product->reviews_score])
```

#### Review form
Expand Down
10 changes: 5 additions & 5 deletions resources/views/reviews.blade.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<graphql v-cloak query='@include('rapidez-reviews::queries.reviews', ['sku' => $product->sku])'>
<graphql v-cloak query='@include('rapidez-reviews::queries.reviews', @compact('sku'))'>
<div slot-scope="{ data }" v-if="data?.products.items[0].reviews">
<strong class="block text-2xl mt-5">@lang('Customer Reviews')</strong>
<div itemprop="aggregateRating" itemtype="https://schema.org/AggregateRating" itemscope>
<meta itemprop="reviewCount" :content="data.products.items[0].reviews.items.length" />
<meta itemprop="ratingValue" :content="data.products.items[0].rating_summary" />
<meta itemprop="reviewCount" content="{{ $reviews_count }}" />
<meta itemprop="ratingValue" content="{{ $reviews_score }}" />
<meta itemprop="bestRating" content="100" />
</div>
<div v-for="review in data.products.items[0].reviews.items" class="w-full bg-gray-200 rounded p-3 mt-3" itemprop="review" itemtype="https://schema.org/Review" itemscope>
Expand All @@ -12,9 +12,9 @@
<span class="ml-2 text-xs">@{{ new Date(review.created_at).toLocaleDateString() }}</span>
</p>
<div itemprop="reviewRating" itemtype="https://schema.org/Rating" itemscope>
<meta itemprop="ratingValue" :content="review.average_rating" />
<meta itemprop="ratingValue" v-bind:content="review.average_rating" />
<meta itemprop="bestRating" content="100" />
<stars class="mt-1" :score="review.average_rating"></stars>
<stars class="mt-1" v-bind:score="review.average_rating"></stars>
</div>
<strong class="block mt-3" itemprop="name">@{{ review.summary }}</strong>
<p class="mt-1 text-sm" itemprop="reviewBody">@{{ review.text }}</p>
Expand Down

0 comments on commit 505d6b9

Please sign in to comment.