reviews issue

This commit is contained in:
rahul shukla 2018-10-25 21:45:28 +05:30
parent 84ba1d4fc6
commit 781b960fa8
10 changed files with 214 additions and 73 deletions

View File

@ -468,7 +468,7 @@ return [
'message' => 'The Page you are looking for doesnt exist or have secrately escaped;head back to home and make a fresh move again.'
],
'403' => [
'page-title' => '403 forbidden',
'page-title' => '403 forbidden Error',
'name' => '403',
'title' => 'Forbidden error',
'message' => 'You do not have permission to access this page'

View File

@ -120,7 +120,7 @@ class Core
'http://' . request()->getHttpHost(),
'https://' . request()->getHttpHost()
])->first();
if(!$channel)
$channel = $this->channelRepository->first();
@ -370,7 +370,7 @@ class Core
{
if(is_null($price))
$price = 0;
return currency($price, $this->getBaseCurrencyCode());
}
@ -523,13 +523,13 @@ class Core
$totalDays = $startDate->diffInDays($endDate);
$totalMonths = $startDate->diffInMonths($endDate);
$startWeekDay = Carbon::createFromTimeString($this->xWeekRange($startDate, 0) . ' 00:00:01');
$endWeekDay = Carbon::createFromTimeString($this->xWeekRange($endDate, 1) . ' 23:59:59');
$totalWeeks = $startWeekDay->diffInWeeks($endWeekDay);
if($totalMonths > 5) {
for ($i = 0; $i < $totalMonths; $i++) {
for ($i = 0; $i < $totalMonths; $i++) {
$date = clone $startDate;
$date->addMonths($i);
@ -541,7 +541,7 @@ class Core
$timeIntervals[] = ['start' => $start, 'end' => $end, 'formatedDate' => $date->format('M')];
}
} elseif($totalWeeks > 6) {
for ($i = 0; $i < $totalWeeks; $i++) {
for ($i = 0; $i < $totalWeeks; $i++) {
$date = clone $startDate;
$date->addWeeks($i);
@ -555,7 +555,7 @@ class Core
$timeIntervals[] = ['start' => $start, 'end' => $end, 'formatedDate' => $date->format('d M')];
}
} else {
for ($i = 0; $i < $totalDays; $i++) {
for ($i = 0; $i < $totalDays; $i++) {
$date = clone $startDate;
$date->addDays($i);

View File

@ -1,6 +1,7 @@
<?php
namespace Webkul\Product\Helpers;
use DB;
class Review extends AbstractProduct
{
@ -56,42 +57,27 @@ class Review extends AbstractProduct
*/
public function getPercentageRating($product)
{
$reviews['five'] = $product->reviews()->where('rating', 5)->where('status','approved')->count();
$reviews = $product->reviews()->where('status','approved')
->select('rating', DB::raw ('count(*) as total'))
->groupBy('rating')
->orderBy('rating','desc')
->get();
$reviews['four'] = $product->reviews()->where('rating', 4)->where('status','approved')->count();
$reviews['three'] = $product->reviews()->where('rating', 3)->where('status','approved')->count();
$reviews['two'] = $product->reviews()->where('rating', 2)->where('status','approved')->count();
$reviews['one'] = $product->reviews()->where('rating', 1)->where('status','approved')->count();
foreach($reviews as $key=>$review){
if($this->getTotalReviews($product) == 0){
$percentage[$key]=0;
}else{
$percentage[$key] = round(($review/$this->getTotalReviews($product))*100);
for($i=5; $i >= 1; $i--) {
if(!$reviews->isEmpty()) {
foreach ($reviews as $review) {
if($review->rating == $i) {
$percentage[$i] = round(($review->total/$this->getTotalReviews($product))*100);
break;
} else {
$percentage[$i]=0;
}
}
} else {
$percentage[$i]=0;
}
}
return $percentage;
}
/**
* Returns the product accroding to paginate
*
* @param Product $product
* @return integer
*/
public function loadMore($product)
{
$link = $_SERVER['PHP_SELF'];
$link_array = explode('/',$link);
$last=end($link_array);
$itemPerPage = 1*5;
return $product->reviews()->where('status','approved')->paginate($itemPerPage);
}
}

View File

@ -1341,7 +1341,7 @@ section.product-detail {
// product pages css ends here
// product pages responsive css start here
@media only screen and (max-width: 720px){
@media only screen and (max-width: 720px) {
section.product-detail div.layouter form {
flex-direction: column;
@ -1395,7 +1395,7 @@ section.product-detail {
}
}
@media only screen and (max-width: 510px){
@media only screen and (max-width: 510px) {
section.product-detail div.layouter form {
div.product-image-group {
.product-hero-image img {
@ -1513,6 +1513,7 @@ section.cart {
}
}
.cart-item-list {
margin-top: 21px;
padding: 1px;
@ -1621,6 +1622,64 @@ section.cart {
}
}
// cart pages responsive css start
@media only screen and (max-width: 770px){
section.cart {
.cart-content {
display: block;
.left-side {
width: 100%;
float: none;
.cart-item-list {
.item {
.item-image {
height: 90px;
width: 90px;
}
.item-details .misc {
margin-left: -105px;
}
}
}
.misc-controls {
position: relative;
top: 200px;
}
}
.right-side {
width: 100%;
padding-left: 0px;
position: relative;
top: -40px;
}
}
}
}
@media only screen and (max-width: 560px){
section.cart {
.cart-content {
.left-side .misc-controls {
display: block;
top: 150px;
div {
margin-top: 10px;
}
}
.right-side {
top: -80px;
}
}
}
}
//cart pages responsive css end
// checkout starts here
.checkout-process {
display: flex;
@ -1945,6 +2004,13 @@ section.review {
.rating {
color: $font-color-light;
.rating-title::after {
content: "*";
color: #FC6868;
font-weight: 700;
display: inline-block;
}
label.star {
font-size: 25px;
color: #d4d4d4;
@ -1956,6 +2022,22 @@ section.review {
}
}
.control-group {
label {
color: $font-color-light;
font-size: 16px;
}
.control {
width: 90%;
color: $font-color-light;
}
}
.control-error {
color: #ff5656;
font-size: 14px;
}
.write-review {
label {
color: $font-color-light;

View File

@ -14,6 +14,7 @@ return [
],
'reviews' => [
'title' => 'Title',
'add-review-page-title' => 'Add Review',
'write-review' => 'Write a review',
'review-title' => 'Give Your Review a Title',

View File

@ -19,7 +19,19 @@
<div class="category-block">
<div class="hero-image mb-35">
<img src="https://images.pexels.com/photos/428338/pexels-photo-428338.jpeg?cs=srgb&dl=adolescent-casual-cute-428338.jpg&fm=jpg" />
{{-- <img src="https://images.pexels.com/photos/428338/pexels-photo-428338.jpeg?cs=srgb&dl=adolescent-casual-cute-428338.jpg&fm=jpg" /> --}}
@if(is_null($category->image))
<img src="https://images.pexels.com/photos/428338/pexels-photo-428338.jpeg?cs=srgb&dl=adolescent-casual-cute-428338.jpg&fm=jpg" />
@else
<?php
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$src=$protocol. request()->getHttpHost().'/bagisto/public/storage/'.$category->image;
?>
<img class="logo" src="{{ $src }}" />
@endif
</div>
<?php $products = $productRepository->findAllByCategory($category->id); ?>

View File

@ -43,7 +43,7 @@
</div>
<div class="review-form">
<form method="POST" action="{{ route('shop.reviews.store', $product->id ) }}">
<form method="POST" action="{{ route('shop.reviews.store', $product->id ) }}" @submit.prevent="onSubmit">
@csrf
<div class="heading mt-10">
<span>{{ __('shop::app.reviews.write-review') }}</span>
@ -62,24 +62,34 @@
<label class="star star-1" for="star-1" onclick="calculateRating(id)" id="5"></label>
<input type="hidden" id="rating" name="rating">
<input type="hidden" id="rating" name="rating" v-validate="'required'">
{{-- <div class="control-error" v-if="errors.has('rating')">@{{ errors.first('rating') }}</div> --}}
</div>
<div>
<input type="name" name="title" class="form-control" placeholder="{{ __('shop::app.reviews.review-title') }}">
<div class="control-group mt-20" :class="[errors.has('title') ? 'has-error' : '']">
<label for="title" class="required">
{{ __('shop::app.reviews.title') }}
</label>
<input type="text" class="control" name="title" v-validate="'required'" value="{{ old('title') }}">
<span class="control-error" v-if="errors.has('title')">@{{ errors.first('title') }}</span>
</div>
<div class="write-review mt-20">
<div class="control-group">
<label for="review">{{ __('admin::app.customers.reviews.comment') }}</label>
<textarea name="comment">
<div class="control-group" :class="[errors.has('title') ? 'has-error' : '']">
<label for="review" class="required">
{{ __('admin::app.customers.reviews.comment') }}
</label>
<textarea type="text" class="control" name="comment" v-validate="'required'" value="{{ old('comment') }}">
</textarea>
<span class="control-error" v-if="errors.has('comment')">@{{ errors.first('comment') }}</span>
</div>
</div>
<a type="submit" class="btn btn-lg btn-primary">
<button type="submit" class="btn btn-lg btn-primary">
{{ __('shop::app.reviews.submit') }}
</a>
</button>
</form>
</div>

View File

@ -89,10 +89,6 @@
</div>
<div class="rating-reviews">
{{-- <div class="rating-header">
{{ __('shop::app.products.reviews-title') }}
</div> --}}
<div class="reviews">
@foreach ($reviewHelper->getReviews($product)->paginate(10) as $review)
@ -130,12 +126,9 @@
</div>
</div>
</div>
</div>
</section>
@endsection
@ -147,22 +140,17 @@
var percentage = {};
<?php foreach ($reviewHelper->getPercentageRating($product) as $key=>$count) { ?>
percentage.<?php echo $key; ?> = <?php echo "'$count';"; ?>
percentage = <?php echo "'$count';"; ?>
id = <?php echo "'$key';"; ?>
idNumber = id + 'star';
document.getElementById(id).style.width = percentage + "%";
document.getElementById(id).style.height = 4 + "px";
document.getElementById(idNumber).innerHTML = id ;
<?php } ?>
var i=5;
for(var key in percentage){
width= percentage[key] ;
let id =key + 'star';
document.getElementById(key).style.width = width + "%";
document.getElementById(key).style.height = 4 + "px";
document.getElementById(id).innerHTML = i ;
i--;
{{-- document.getElementById(id).innerHTML = i + '\xa0\xa0' + "star"; --}}
}
})();
</script>

View File

@ -2081,6 +2081,46 @@ section.cart .cart-content .right-side {
float: right;
}
@media only screen and (max-width: 770px) {
section.cart .cart-content {
display: block;
}
section.cart .cart-content .left-side {
width: 100%;
float: none;
}
section.cart .cart-content .left-side .cart-item-list .item .item-image {
height: 90px;
width: 90px;
}
section.cart .cart-content .left-side .cart-item-list .item .item-details .misc {
margin-left: -105px;
}
section.cart .cart-content .left-side .misc-controls {
position: relative;
top: 200px;
}
section.cart .cart-content .right-side {
width: 100%;
padding-left: 0px;
position: relative;
top: -40px;
}
}
@media only screen and (max-width: 560px) {
section.cart .cart-content .left-side .misc-controls {
display: block;
top: 150px;
}
section.cart .cart-content .left-side .misc-controls div {
margin-top: 10px;
}
section.cart .cart-content .right-side {
top: -80px;
}
}
.checkout-process {
display: -webkit-box;
display: -ms-flexbox;
@ -2395,6 +2435,13 @@ section.review .review-layouter .review-form .rating {
color: #A5A5A5;
}
section.review .review-layouter .review-form .rating .rating-title::after {
content: "*";
color: #FC6868;
font-weight: 700;
display: inline-block;
}
section.review .review-layouter .review-form .rating label.star {
font-size: 25px;
color: #d4d4d4;
@ -2406,6 +2453,21 @@ section.review .review-layouter .review-form .rating label.star:before {
content: '\2605';
}
section.review .review-layouter .review-form .control-group label {
color: #A5A5A5;
font-size: 16px;
}
section.review .review-layouter .review-form .control-group .control {
width: 90%;
color: #A5A5A5;
}
section.review .review-layouter .review-form .control-error {
color: #ff5656;
font-size: 14px;
}
section.review .review-layouter .review-form .write-review label {
color: #A5A5A5;
font-size: 16px;

File diff suppressed because one or more lines are too long