guest review
This commit is contained in:
parent
a7f545fcf4
commit
59ecc0f019
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'key' => 'catalog',
|
||||
'name' => 'Catalog',
|
||||
'sort' => 1
|
||||
], [
|
||||
'key' => 'catalog.products',
|
||||
'name' => 'Products',
|
||||
'sort' => 1,
|
||||
], [
|
||||
'key' => 'catalog.products.review',
|
||||
'name' => 'Review',
|
||||
'sort' => 1,
|
||||
'fields' => [
|
||||
[
|
||||
'name' => 'guest_review',
|
||||
'title' => 'Allow Guest Review',
|
||||
'type' => 'select',
|
||||
'options' => [
|
||||
[
|
||||
'title' => 'Yes',
|
||||
'value' => true
|
||||
], [
|
||||
'title' => 'No',
|
||||
'value' => false
|
||||
]
|
||||
],
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
|
|
@ -44,7 +44,7 @@ class AdminServiceProvider extends ServiceProvider
|
|||
Handler::class
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
|
|
@ -115,7 +115,7 @@ class AdminServiceProvider extends ServiceProvider
|
|||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register package config.
|
||||
*
|
||||
|
|
@ -130,5 +130,9 @@ class AdminServiceProvider extends ServiceProvider
|
|||
$this->mergeConfigFrom(
|
||||
dirname(__DIR__) . '/Config/acl.php', 'acl'
|
||||
);
|
||||
|
||||
$this->mergeConfigFrom(
|
||||
dirname(__DIR__) . '/Config/system.php', 'core'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AlterProductReviewsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('product_reviews', function (Blueprint $table) {
|
||||
$table->string('name');
|
||||
$table->dropForeign('product_reviews_customer_id_foreign');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AlterCustomerIdNullableInProductReviewsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('product_reviews', function (Blueprint $table) {
|
||||
$table->integer('customer_id')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('product_reviews', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ use Webkul\Product\Contracts\ProductReview as ProductReviewContract;
|
|||
|
||||
class ProductReview extends Model implements ProductReviewContract
|
||||
{
|
||||
protected $fillable = ['comment', 'title', 'rating', 'status', 'product_id', 'customer_id'];
|
||||
protected $fillable = ['comment', 'title', 'rating', 'status', 'product_id', 'customer_id', 'name'];
|
||||
|
||||
/**
|
||||
* Get the product attribute family that owns the product.
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ return [
|
|||
], [
|
||||
'name' => 'active',
|
||||
'title' => 'Status',
|
||||
'type' => 'select',
|
||||
'type' => 'multiselect',
|
||||
'options' => [
|
||||
[
|
||||
'title' => 'Active',
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ class ReviewController extends Controller
|
|||
*/
|
||||
public function __construct(Product $product, ProductReview $productReview)
|
||||
{
|
||||
$this->middleware('customer')->only(['create', 'store', 'destroy']);
|
||||
|
||||
$this->product = $product;
|
||||
|
||||
$this->productReview = $productReview;
|
||||
|
|
@ -65,7 +63,9 @@ class ReviewController extends Controller
|
|||
{
|
||||
$product = $this->product->findBySlugOrFail($slug);
|
||||
|
||||
return view($this->_config['view'], compact('product'));
|
||||
$guest_review = core()->getConfigData('catalog.products.review.guest_review');
|
||||
|
||||
return view($this->_config['view'], compact('product', 'guest_review'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,11 +84,13 @@ class ReviewController extends Controller
|
|||
|
||||
$data = request()->all();
|
||||
|
||||
$customer_id = auth()->guard('customer')->user()->id;
|
||||
if (auth()->guard('customer')->user()) {
|
||||
$data['customer_id'] = auth()->guard('customer')->user()->id;
|
||||
$data['name'] = auth()->guard('customer')->user()->first_name .' ' . auth()->guard('customer')->user()->last_name;
|
||||
}
|
||||
|
||||
$data['status'] = 'pending';
|
||||
$data['product_id'] = $id;
|
||||
$data['customer_id'] = $customer_id;
|
||||
|
||||
$this->productReview->create($data);
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ Route::group(['middleware' => ['web', 'theme', 'locale', 'currency']], function
|
|||
|
||||
// Show Product Review Form Store
|
||||
Route::post('/product/{slug}/review', 'Webkul\Shop\Http\Controllers\ReviewController@store')->defaults('_config', [
|
||||
'redirect' => 'customer.reviews.index'
|
||||
'redirect' => 'shop.home.index'
|
||||
])->name('shop.reviews.store');
|
||||
|
||||
//customer routes starts here
|
||||
|
|
|
|||
|
|
@ -80,7 +80,8 @@ return [
|
|||
'ratingreviews' => ':rating Ratings & :review Reviews',
|
||||
'star' => 'Star',
|
||||
'percentage' => ':percentage %',
|
||||
'id-star' => 'star'
|
||||
'id-star' => 'star',
|
||||
'name' => 'Name'
|
||||
],
|
||||
|
||||
'customer' => [
|
||||
|
|
|
|||
|
|
@ -75,6 +75,16 @@
|
|||
<span class="control-error" v-if="errors.has('title')">@{{ errors.first('title') }}</span>
|
||||
</div>
|
||||
|
||||
@if ($guest_review && !auth()->guard('customer')->user())
|
||||
<div class="control-group" :class="[errors.has('name') ? 'has-error' : '']">
|
||||
<label for="title" class="required">
|
||||
{{ __('shop::app.reviews.name') }}
|
||||
</label>
|
||||
<input type="text" class="control" name="name" v-validate="'required'" value="{{ old('name') }}">
|
||||
<span class="control-error" v-if="errors.has('name')">@{{ errors.first('name') }}</span>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="control-group" :class="[errors.has('comment') ? 'has-error' : '']">
|
||||
<label for="comment" class="required">
|
||||
{{ __('admin::app.customers.reviews.comment') }}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,11 @@
|
|||
<div class="heading mt-10">
|
||||
<span> {{ __('shop::app.reviews.rating-reviews') }} </span>
|
||||
|
||||
<a href="{{ route('shop.reviews.create', $product->url_key) }}" class="btn btn-lg btn-primary right"> {{ __('shop::app.products.write-review-btn') }}</a>
|
||||
@if (core()->getConfigData('catalog.products.review.guest_review') || auth()->guard('customer')->check())
|
||||
<a href="{{ route('shop.reviews.create', $product->url_key) }}" class="btn btn-lg btn-primary right">
|
||||
{{ __('shop::app.products.write-review-btn') }}
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="ratings-reviews mt-35">
|
||||
|
|
@ -112,7 +116,7 @@
|
|||
|
||||
<div class="reviewer-details">
|
||||
<span class="by">
|
||||
{{ __('shop::app.products.by', ['name' => $review->customer->name]) }},
|
||||
{{ __('shop::app.products.by', ['name' => $review->name]) }},
|
||||
</span>
|
||||
|
||||
<span class="when">
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@
|
|||
|
||||
</div>
|
||||
|
||||
@auth('customer')
|
||||
<a href="{{ route('shop.reviews.create', $product->url_key) }}" class="btn btn-lg btn-primary">
|
||||
{{ __('shop::app.products.write-review-btn') }}
|
||||
</a>
|
||||
@endauth
|
||||
@if (core()->getConfigData('catalog.products.review.guest_review') || auth()->guard('customer')->check())
|
||||
<a href="{{ route('shop.reviews.create', $product->url_key) }}" class="btn btn-lg btn-primary">
|
||||
{{ __('shop::app.products.write-review-btn') }}
|
||||
</a>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
<div class="reviewer-details">
|
||||
<span class="by">
|
||||
{{ __('shop::app.products.by', ['name' => $review->customer->name]) }},
|
||||
{{ __('shop::app.products.by', ['name' => $review->name]) }},
|
||||
</span>
|
||||
|
||||
<span class="when">
|
||||
|
|
@ -76,7 +76,7 @@
|
|||
</div>
|
||||
</div>
|
||||
@else
|
||||
@auth('customer')
|
||||
@if (core()->getConfigData('catalog.products.review.guest_review') || auth()->guard('customer')->check())
|
||||
<div class="rating-reviews">
|
||||
<div class="rating-header">
|
||||
<a href="{{ route('shop.reviews.create', $product->url_key) }}" class="btn btn-lg btn-primary">
|
||||
|
|
@ -84,7 +84,7 @@
|
|||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endauth
|
||||
@endif
|
||||
@endif
|
||||
|
||||
{!! view_render_event('bagisto.shop.products.view.reviews.after', ['product' => $product]) !!}
|
||||
Loading…
Reference in New Issue