fixed issue #749
This commit is contained in:
parent
91b4d1f955
commit
4a2efc8eee
|
|
@ -115,6 +115,8 @@ class AddressController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
session()->flash('warning', trans('shop::app.security-warning'));
|
||||
|
||||
return redirect()->route('customer.address.index');
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +153,7 @@ class AddressController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
session()->flash('success', trans('shop::app.security-warning'));
|
||||
session()->flash('warning', trans('shop::app.security-warning'));
|
||||
|
||||
return redirect()->route('customer.address.index');
|
||||
}
|
||||
|
|
@ -185,16 +187,18 @@ class AddressController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
if (request()->is('customer/*') || request()->is('admin/*')) {
|
||||
$this->address->delete($id);
|
||||
$addresses = $this->customer->addresses;
|
||||
|
||||
session()->flash('success', trans('shop::app.customer.account.address.delete.success'));
|
||||
foreach($addresses as $address) {
|
||||
if($id == $address->id) {
|
||||
$this->address->delete($id);
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
session()->flash('warning', trans('shop::app.security-warning'));
|
||||
session()->flash('success', trans('shop::app.customer.account.address.delete.success'));
|
||||
|
||||
return redirect()->route('customer.address.index');
|
||||
return redirect()->route('customer.address.index');
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('customer.address.index');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ class WishlistController extends Controller
|
|||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
$this->wishlist = $wishlist;
|
||||
|
||||
$this->product = $product;
|
||||
|
|
@ -104,29 +102,22 @@ class WishlistController extends Controller
|
|||
* @param integer $itemId
|
||||
*/
|
||||
public function remove($itemId) {
|
||||
$found = $this->wishlist->find($itemId);
|
||||
|
||||
if(isset($found)) {
|
||||
$found = true;
|
||||
} else {
|
||||
$found = false;
|
||||
}
|
||||
$customerWishlistItems = auth()->guard('customer')->user()->wishlist_items;
|
||||
|
||||
if($found) {
|
||||
$result = $this->wishlist->deleteWhere(['customer_id' => auth()->guard('customer')->user()->id, 'channel_id' => core()->getCurrentChannel()->id, 'id' => $itemId]);
|
||||
foreach($customerWishlistItems as $customerWishlistItem) {
|
||||
if($itemId == $customerWishlistItem->id) {
|
||||
$this->wishlist->delete($itemId);
|
||||
|
||||
if ($result) {
|
||||
session()->flash('success', trans('customer::app.wishlist.removed'));
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
session()->flash('error', trans('customer::app.wishlist.remove-fail'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
} else {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
session()->flash('error', trans('customer::app.wishlist.remove-fail'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -136,6 +127,13 @@ class WishlistController extends Controller
|
|||
*/
|
||||
public function move($itemId) {
|
||||
$wishlistItem = $this->wishlist->findOneByField('id', $itemId);
|
||||
|
||||
if(!isset($wishlistItem) || $wishlistItem->customer_id != auth()->guard('customer')->user()->id) {
|
||||
session()->flash('warning', trans('shop::app.security-warning'));
|
||||
|
||||
return redirect()->route( 'customer.wishlist.index');
|
||||
}
|
||||
|
||||
$result = Cart::moveToCart($wishlistItem);
|
||||
|
||||
if ($result == 1) {
|
||||
|
|
@ -151,7 +149,7 @@ class WishlistController extends Controller
|
|||
return redirect()->back();
|
||||
}
|
||||
} else if ($result == 0) {
|
||||
Session('error', trans('shop::app.wishlist.error'));
|
||||
session()->flash('error', trans('shop::app.wishlist.error'));
|
||||
|
||||
return redirect()->back();
|
||||
} else if ($result == -1) {
|
||||
|
|
@ -184,4 +182,4 @@ class WishlistController extends Controller
|
|||
session()->flash('success', trans('customer::app.wishlist.remove-all-success'));
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,4 +96,11 @@ class Customer extends Authenticatable implements CustomerContract
|
|||
public function all_reviews() {
|
||||
return $this->hasMany(ProductReviewProxy::modelClass(), 'customer_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* get all orders of a customer
|
||||
*/
|
||||
public function all_orders() {
|
||||
return $this->hasMany(OrderProxy::modelClass(), 'customer_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,6 @@
|
|||
"vee-validate": "2.0.0-rc.26",
|
||||
"vue-flatpickr": "^2.3.0",
|
||||
"vue-slider-component": "^2.7.5",
|
||||
"ez-plus":"^1.2.1"
|
||||
"ez-plus": "^1.2.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,9 +82,17 @@ class OrderController extends Controller
|
|||
*/
|
||||
public function view($id)
|
||||
{
|
||||
$order = $this->order->find($id);
|
||||
$orders = auth()->guard('customer')->user()->all_orders;
|
||||
|
||||
if(isset($orders) && count($orders)) {
|
||||
$order = $orders->first();
|
||||
|
||||
return view($this->_config['view'], compact('order'));
|
||||
} else {
|
||||
return redirect()->route( 'customer.orders.index');
|
||||
}
|
||||
|
||||
|
||||
return view($this->_config['view'], compact('order'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,4 +109,4 @@ class OrderController extends Controller
|
|||
|
||||
return $pdf->download('invoice-' . $invoice->created_at->format('d-m-Y') . '.pdf');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ class ReviewController extends Controller
|
|||
|
||||
$data = request()->all();
|
||||
|
||||
|
||||
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;
|
||||
|
|
@ -96,7 +97,7 @@ class ReviewController extends Controller
|
|||
|
||||
session()->flash('success', trans('shop::app.response.submit-success', ['name' => 'Product Review']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
return [
|
||||
'security-warning' => 'Suspicious Activity Found!!!',
|
||||
'nothing-to-delete' => 'Nothing to delete',
|
||||
|
||||
'layouts' => [
|
||||
'my-account' => 'My Account',
|
||||
|
|
@ -501,4 +502,4 @@ return [
|
|||
'delete-success' => ':name deleted successfully.',
|
||||
'submit-success' => ':name submitted successfully.'
|
||||
],
|
||||
];
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue