Before merge wishlist in progress
This commit is contained in:
parent
0177d889c3
commit
70da40c855
|
|
@ -27,7 +27,7 @@ class CreateWishlistTable extends Migration
|
|||
$table->json('item_options')->nullable();
|
||||
$table->date('moved_to_cart')->nullable();
|
||||
$table->boolean('shared')->nullable();
|
||||
$table->date('time_of_moving');
|
||||
$table->date('time_of_moving')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace Webkul\Customer\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Customer\Repositories\WishlistRepository;
|
||||
use Auth;
|
||||
|
||||
/**
|
||||
|
|
@ -18,41 +19,43 @@ use Auth;
|
|||
*/
|
||||
class WishlistController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
|
||||
protected $_config;
|
||||
|
||||
protected $customer;
|
||||
|
||||
protected $wishlist;
|
||||
|
||||
public function __construct(CustomerRepository $customer)
|
||||
/**
|
||||
* Initializes the required repository instances.
|
||||
*
|
||||
* @param $customer
|
||||
* @param $wishlist
|
||||
*/
|
||||
public function __construct(CustomerRepository $customer, WishlistRepository $wishlist)
|
||||
{
|
||||
$this->middleware('customer');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
$this->wishlist = $wishlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* For taking the customer
|
||||
* to the dashboard after
|
||||
* authentication
|
||||
* @return view
|
||||
* Displays the listing resources if the customer having items in wishlist.
|
||||
*/
|
||||
private function getCustomer($id) {
|
||||
$customer = collect($this->customer->findOneWhere(['id'=>$id]));
|
||||
return $customer;
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$id = auth()->guard('customer')->user()->id;
|
||||
$wishlists = $this->wishlist->findWhere(['channel_id' => core()->getCurrentChannel()->id,'customer_id' => auth()->guard('customer')->user()->id]);
|
||||
|
||||
$customer = $this->getCustomer($id);
|
||||
$wishlistItems = array();
|
||||
|
||||
return view($this->_config['view'])->with('customer', $customer);
|
||||
foreach($wishlists as $wishlist) {
|
||||
array_push($wishlistItems, $this->wishlist->getItemsWithProducts($wishlist->id));
|
||||
}
|
||||
|
||||
return view($this->_config['view'])->with('items', $wishlistItems);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -61,7 +64,30 @@ class WishlistController extends Controller
|
|||
* @param integer $itemId
|
||||
*/
|
||||
public function add($itemId) {
|
||||
dd('adding item to wishlist');
|
||||
|
||||
$data = [
|
||||
'channel_id' => core()->getCurrentChannel()->id,
|
||||
'product_id' => $itemId,
|
||||
'customer_id' => auth()->guard('customer')->user()->id
|
||||
];
|
||||
|
||||
$checked = $this->wishlist->findWhere(['channel_id' => core()->getCurrentChannel()->id, 'product_id' => $itemId, 'customer_id' => auth()->guard('customer')->user()->id]);
|
||||
|
||||
if($checked->isEmpty()) {
|
||||
if($this->wishlist->create($data)) {
|
||||
session()->flash('success', trans('customer::app.wishlist.success'));
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
session()->flash('error', trans('customer::app.wishlist.failure'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
} else {
|
||||
session()->flash('warning', trans('customer::app.wishlist.already'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +96,16 @@ class WishlistController extends Controller
|
|||
* @param integer $itemId
|
||||
*/
|
||||
public function remove($itemId) {
|
||||
dd('removing item to wishlist');
|
||||
|
||||
if($this->wishlist->deleteWhere(['customer_id' => auth()->guard('customer')->user()->id, 'channel_id' => core()->getCurrentChannel()->id, 'product_id' => $itemId])) {
|
||||
session()->flash('success', trans('customer::app.wishlist.remove'));
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
session()->flash('error', trans('customer::app.wishlist.remove-fail'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,10 +3,15 @@
|
|||
namespace Webkul\Customer\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Product\Models\Product;
|
||||
|
||||
class Wishlist extends Model
|
||||
{
|
||||
protected $table = 'wishlist';
|
||||
|
||||
protected $fillable = ['channel_id', 'product_id', 'customer_id', 'item_options','moved_to_cart','shared','time_of_moving'];
|
||||
|
||||
public function item_wishlist() {
|
||||
return $this->belongsTo(Product::class, 'product_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ class CustomerServiceProvider extends ServiceProvider
|
|||
{
|
||||
$router->aliasMiddleware('customer', RedirectIfNotCustomer::class);
|
||||
|
||||
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'customer');
|
||||
|
||||
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
|
||||
|
||||
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'customer');
|
||||
|
|
|
|||
|
|
@ -51,4 +51,14 @@ class WishlistRepository extends Repository
|
|||
|
||||
return $wishlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* To retrieve products with wishlist m
|
||||
* for a listing resource.
|
||||
*
|
||||
* @param integer $id
|
||||
*/
|
||||
public function getItemsWithProducts($id) {
|
||||
return $this->model->find($id)->item_wishlist;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'wishlist' => [
|
||||
'success' => 'Item Successfully Added To Wishlist',
|
||||
'failure' => 'Item Cannot Be Added To Wishlist',
|
||||
'already' => 'Item Already Present In Your Wishlist',
|
||||
'removed' => 'Item Successfully Added To Wishlist',
|
||||
'remove-fail' => 'Item Cannot Be Removed From Wishlist',
|
||||
'empty' => 'You Don\'t Have Any Items In Your Wishlist'
|
||||
],
|
||||
];
|
||||
|
|
@ -151,7 +151,7 @@ Route::group(['middleware' => ['web']], function () {
|
|||
/* Routes for Addresses ends here */
|
||||
|
||||
/* Wishlist route */
|
||||
Route::get('wishlist', 'Webkul\Customer\Http\Controllers\WishlistController@wishlist')->defaults('_config', [
|
||||
Route::get('wishlist', 'Webkul\Customer\Http\Controllers\WishlistController@index')->defaults('_config', [
|
||||
'view' => 'shop::customers.account.wishlist.wishlist'
|
||||
])->name('customer.wishlist.index');
|
||||
|
||||
|
|
|
|||
|
|
@ -421,7 +421,7 @@ section.slider-block {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ul.right-responsive {
|
||||
display: none;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,46 @@
|
|||
}
|
||||
}
|
||||
|
||||
//wishlist item
|
||||
.wishlist-item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 125px;
|
||||
|
||||
.media-info {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
.media {
|
||||
height: 125px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.info {
|
||||
display: block;
|
||||
margin-left: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.operations {
|
||||
height: 120px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
|
||||
a {
|
||||
width: 100%;
|
||||
span {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//product page price styles
|
||||
.product-price {
|
||||
margin-bottom: 14px;
|
||||
|
|
@ -125,3 +165,9 @@
|
|||
}
|
||||
}
|
||||
|
||||
//horizontal rule
|
||||
.horizontal-rule {
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background: $border-color;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ return [
|
|||
'choose-option' => 'Choose an option'
|
||||
],
|
||||
|
||||
'wishlist' => [
|
||||
'title' => 'Wishlist',
|
||||
'deleteall' => 'Delete All',
|
||||
'moveall' => 'Move All Products To Cart'
|
||||
],
|
||||
|
||||
'checkout' => [
|
||||
'cart' => [
|
||||
'integrity' => [
|
||||
|
|
|
|||
|
|
@ -1 +1,56 @@
|
|||
<h1>Wishlist page here</h1>
|
||||
@extends('shop::layouts.master')
|
||||
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="account-content">
|
||||
@inject ('productImageHelper', 'Webkul\Product\Product\ProductImage')
|
||||
|
||||
@include('shop::customers.account.partials.sidemenu')
|
||||
|
||||
<div class="profile">
|
||||
|
||||
<div class="section-head">
|
||||
<span class="profile-heading">{{ __('shop::app.wishlist.title') }}</span>
|
||||
|
||||
@if(count($items))
|
||||
<div class="profile-edit">
|
||||
<a href="" style="margin-right: 15px;">{{ __('shop::app.wishlist.deleteall') }}</a>
|
||||
<a href="">{{ __('shop::app.wishlist.moveall') }}</a>
|
||||
</div>
|
||||
@endif
|
||||
<div class="horizontal-rule"></div>
|
||||
</div>
|
||||
|
||||
<div class="profile-content">
|
||||
|
||||
@if(count($items))
|
||||
@foreach($items as $item)
|
||||
<div class="wishlist-item mb-10">
|
||||
<div class="media-info">
|
||||
@php
|
||||
$image = $productImageHelper->getProductBaseImage($item);
|
||||
@endphp
|
||||
<img class="media" src="{{ $image['small_image_url'] }}" />
|
||||
|
||||
<div class="info mt-20">
|
||||
<div class="product-name">{{$item->name}}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="operations">
|
||||
<a class="mb-50" href="{{ route('customer.wishlist.remove', $item->id) }}"><span class="icon trash-icon"></span></a>
|
||||
|
||||
<button class="btn btn-primary btn-md">Move To Cart</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="horizontal-rule mb-10 mt-10"></div>
|
||||
@endforeach
|
||||
@else
|
||||
<div class="empty">
|
||||
{{ __('customer::app.wishlist.empty') }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
@auth('customer')
|
||||
@if($product->type == "simple")
|
||||
<a class="add-to-wishlist" href="{{ route('customer.wishlist.add', $product->id) }}">
|
||||
<span class="icon wishlist-icon"></span>
|
||||
</a>
|
||||
@endif
|
||||
@endauth
|
||||
|
|
|
|||
|
|
@ -182,6 +182,69 @@
|
|||
background-image: url("../images/wishadd.svg");
|
||||
}
|
||||
|
||||
.wishlist-item {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
-webkit-box-pack: justify;
|
||||
-ms-flex-pack: justify;
|
||||
justify-content: space-between;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 125px;
|
||||
}
|
||||
|
||||
.wishlist-item .media-info {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: horizontal;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.wishlist-item .media-info .media {
|
||||
height: 125px;
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.wishlist-item .media-info .info {
|
||||
display: block;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.wishlist-item .operations {
|
||||
height: 120px;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-box-direction: normal;
|
||||
-ms-flex-direction: column;
|
||||
flex-direction: column;
|
||||
-webkit-box-pack: start;
|
||||
-ms-flex-pack: start;
|
||||
justify-content: flex-start;
|
||||
-webkit-box-align: center;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.wishlist-item .operations a {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wishlist-item .operations a span {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
margin-bottom: 14px;
|
||||
width: 100%;
|
||||
|
|
@ -203,6 +266,12 @@
|
|||
color: #FF6472;
|
||||
}
|
||||
|
||||
.horizontal-rule {
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background: #E8E8E8;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue