This commit is contained in:
jitendra 2022-03-31 10:20:41 +05:30
parent 04a7e7a4c0
commit 000cf6481a
1 changed files with 10 additions and 9 deletions

View File

@ -82,23 +82,26 @@ class ReviewController extends Controller
'title' => 'required',
]);
$data = request()->all();
$product = $this->productRepository->find($id);
$data = array_merge(request()->all(), [
'status' => 'pending',
'product_id' => $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;
$review = $this->productReviewRepository->create($data);
$this->productReviewImageRepository->uploadImages($data, $review);
session()->flash('success', trans('shop::app.response.submit-success', ['name' => 'Product Review']));
return redirect()->route($this->_config['redirect']);
return redirect()->route('shop.productOrCategory.index', $product->url_key);
}
/**
@ -147,10 +150,8 @@ class ReviewController extends Controller
{
$reviews = auth()->guard('customer')->user()->all_reviews;
if ($reviews->count() > 0) {
foreach ($reviews as $review) {
$this->productReviewRepository->delete($review->id);
}
foreach ($reviews as $review) {
$this->productReviewRepository->delete($review->id);
}
session()->flash('success', trans('shop::app.reviews.delete-all'));