Fixed issue #749 for all customer resources profile, wishlist, reviews, orders and addresses
This commit is contained in:
parent
4a2efc8eee
commit
40ebb3a0c4
|
|
@ -77,7 +77,7 @@ class CustomerController extends Controller
|
|||
*
|
||||
* @return View
|
||||
*/
|
||||
public function editIndex()
|
||||
public function edit()
|
||||
{
|
||||
$customer = $this->customer->find(auth()->guard('customer')->user()->id);
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ class CustomerController extends Controller
|
|||
*
|
||||
* @return Redirect.
|
||||
*/
|
||||
public function edit()
|
||||
public function update()
|
||||
{
|
||||
$id = auth()->guard('customer')->user()->id;
|
||||
|
||||
|
|
@ -124,34 +124,14 @@ class CustomerController extends Controller
|
|||
if ($this->customer->update($data, $id)) {
|
||||
Session()->flash('success', trans('shop::app.customer.account.profile.edit-success'));
|
||||
|
||||
return redirect()->back();
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
} else {
|
||||
Session()->flash('success', trans('shop::app.customer.account.profile.edit-fail'));
|
||||
|
||||
return redirect()->back();
|
||||
return redirect()->back($this->_config['redirect']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the view for the customer account panel, showing orders in a table.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function orders()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the view for the customer account panel, showing wishlist items.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function wishlist()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the view for the customer account panel, showing approved reviews.
|
||||
*
|
||||
|
|
@ -159,18 +139,8 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function reviews()
|
||||
{
|
||||
$reviews = $this->productReview->getCustomerReview();
|
||||
$reviews = auth()->guard('customer')->user()->all_reviews;
|
||||
|
||||
return view($this->_config['view'], compact('reviews'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the view for the customer account panel, shows the customer address.
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function address()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Shop\Http\Controllers;
|
||||
namespace Webkul\Customer\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
|
@ -67,9 +67,7 @@ class OrderController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
$orders = $this->order->findWhere([
|
||||
'customer_id' => auth()->guard('customer')->user()->id
|
||||
]);
|
||||
$orders = auth()->guard('customer')->user()->all_orders;
|
||||
|
||||
return view($this->_config['view'], compact('orders'));
|
||||
}
|
||||
|
|
@ -91,8 +89,6 @@ class OrderController extends Controller
|
|||
} else {
|
||||
return redirect()->route( 'customer.orders.index');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -11,8 +11,7 @@ use Cart;
|
|||
use Auth;
|
||||
|
||||
/**
|
||||
* Customer controlller for the customer basically for the tasks of customers which will be done
|
||||
* after customer authenticastion.
|
||||
* Customer controller
|
||||
*
|
||||
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
|
|
@ -65,6 +64,10 @@ class WishlistController extends Controller
|
|||
public function add($itemId) {
|
||||
$product = $this->product->findOneByField('id', $itemId);
|
||||
|
||||
if(!$product->status) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$data = [
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
'product_id' => $itemId,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ 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;
|
||||
|
|
@ -97,11 +96,11 @@ class ReviewController extends Controller
|
|||
|
||||
session()->flash('success', trans('shop::app.response.submit-success', ['name' => 'Product Review']));
|
||||
|
||||
return redirect()->back();
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display reviews accroding to product.
|
||||
* Display reviews of particular product.
|
||||
*
|
||||
* @param string $slug
|
||||
* @return \Illuminate\Http\Response
|
||||
|
|
@ -114,21 +113,31 @@ class ReviewController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete the review of the current product
|
||||
* Customer delete a reviews from their account
|
||||
*
|
||||
* @return response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->productReview->delete($id);
|
||||
$reviews = auth()->guard('customer')->user()->all_reviews;
|
||||
|
||||
session()->flash('success', trans('shop::app.response.delete-success', ['name' => 'Product Review']));
|
||||
if ($reviews->count() > 0) {
|
||||
foreach ($reviews as $review) {
|
||||
if($review->id == $id) {
|
||||
$this->productReview->delete($id);
|
||||
|
||||
return redirect()->back();
|
||||
session()->flash('success', trans('shop::app.response.delete-success', ['name' => 'Product Review']));
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to delete all reviews
|
||||
* Customer delete all reviews from their account
|
||||
*
|
||||
* @return Mixed Response & Boolean
|
||||
*/
|
||||
|
|
@ -143,6 +152,6 @@ class ReviewController extends Controller
|
|||
|
||||
session()->flash('success', trans('shop::app.reviews.delete-all'));
|
||||
|
||||
return redirect()->back();
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -191,13 +191,13 @@ Route::group(['middleware' => ['web', 'theme', 'locale', 'currency']], function
|
|||
])->name('customer.profile.index');
|
||||
|
||||
//Customer Profile Edit Form Show
|
||||
Route::get('profile/edit', 'Webkul\Customer\Http\Controllers\CustomerController@editIndex')->defaults('_config', [
|
||||
Route::get('profile/edit', 'Webkul\Customer\Http\Controllers\CustomerController@edit')->defaults('_config', [
|
||||
'view' => 'shop::customers.account.profile.edit'
|
||||
])->name('customer.profile.edit');
|
||||
|
||||
//Customer Profile Edit Form Store
|
||||
Route::post('profile/edit', 'Webkul\Customer\Http\Controllers\CustomerController@edit')->defaults('_config', [
|
||||
'view' => 'shop::customers.account.profile.edit'
|
||||
Route::post('profile/edit', 'Webkul\Customer\Http\Controllers\CustomerController@update')->defaults('_config', [
|
||||
'redirect' => 'shop::customers.account.index'
|
||||
])->name('customer.profile.edit');
|
||||
/* Profile Routes Ends Here */
|
||||
|
||||
|
|
@ -242,17 +242,17 @@ Route::group(['middleware' => ['web', 'theme', 'locale', 'currency']], function
|
|||
|
||||
/* Orders route */
|
||||
//Customer orders(listing)
|
||||
Route::get('orders', 'Webkul\Shop\Http\Controllers\OrderController@index')->defaults('_config', [
|
||||
Route::get('orders', 'Webkul\Customer\Http\Controllers\OrderController@index')->defaults('_config', [
|
||||
'view' => 'shop::customers.account.orders.index'
|
||||
])->name('customer.orders.index');
|
||||
|
||||
//Customer orders view summary and status
|
||||
Route::get('orders/view/{id}', 'Webkul\Shop\Http\Controllers\OrderController@view')->defaults('_config', [
|
||||
Route::get('orders/view/{id}', 'Webkul\Customer\Http\Controllers\OrderController@view')->defaults('_config', [
|
||||
'view' => 'shop::customers.account.orders.view'
|
||||
])->name('customer.orders.view');
|
||||
|
||||
//Prints invoice
|
||||
Route::get('orders/print/{id}', 'Webkul\Shop\Http\Controllers\OrderController@print')->defaults('_config', [
|
||||
Route::get('orders/print/{id}', 'Webkul\Customer\Http\Controllers\OrderController@print')->defaults('_config', [
|
||||
'view' => 'shop::customers.account.orders.print'
|
||||
])->name('customer.orders.print');
|
||||
|
||||
|
|
|
|||
|
|
@ -31,18 +31,16 @@
|
|||
@php
|
||||
$image = $productImageHelper->getProductBaseImage($item->product);
|
||||
@endphp
|
||||
<img class="media" src="{{ $image['small_image_url'] }}" />
|
||||
{{-- <a href="{{ url()->to('/').'/products/'.$item->product->url_key }}" title="{{ $item->product->name }}">
|
||||
|
||||
</a> --}}
|
||||
<img class="media" src="{{ $image['small_image_url'] }}" />
|
||||
|
||||
<div class="info">
|
||||
<div class="product-name">
|
||||
{{$item->product->name}}
|
||||
{{-- <a href="{{ url()->to('/').'/products/'.$item->product->url_key }}" title="{{ $item->product->name }}">
|
||||
|
||||
</a> --}}
|
||||
</div>
|
||||
|
||||
@inject ('reviewHelper', 'Webkul\Product\Helpers\Review')
|
||||
|
||||
<span class="stars" style="display: inline">
|
||||
@for($i=1;$i<=$reviewHelper->getAverageRating($item->product);$i++)
|
||||
<span class="icon star-icon"></span>
|
||||
|
|
@ -59,6 +57,7 @@
|
|||
</div>
|
||||
<div class="horizontal-rule mb-10 mt-10"></div>
|
||||
@endforeach
|
||||
|
||||
@else
|
||||
<div class="empty">
|
||||
{{ __('customer::app.wishlist.empty') }}
|
||||
|
|
|
|||
Loading…
Reference in New Issue