Merge branch 'development' of http://github.com/prashant-webkul/bagisto into development

This commit is contained in:
Prashant Singh 2019-05-13 01:08:55 +05:30
commit c1e5dee96b
91 changed files with 2360 additions and 454 deletions

View File

@ -0,0 +1,115 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Webkul\Customer\Repositories\CustomerAddressRepository;
use Webkul\API\Http\Resources\Customer\CustomerAddress as CustomerAddressResource;
/**
* Address controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class AddressController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* CustomerAddressRepository object
*
* @var Object
*/
protected $customerAddressRepository;
/**
* Controller instance
*
* @param Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
*/
public function __construct(
CustomerAddressRepository $customerAddressRepository
)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
$this->middleware('auth:' . $this->guard);
$this->_config = request('_config');
$this->customerAddressRepository = $customerAddressRepository;
}
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function store()
{
$customer = auth($this->guard)->user();
request()->merge([
'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
'customer_id' => $customer->id
]);
$this->validate(request(), [
'address1' => 'string|required',
'country' => 'string|required',
'state' => 'string|required',
'city' => 'string|required',
'postcode' => 'required',
'phone' => 'required'
]);
$customerAddress = $this->customerAddressRepository->create(request()->all());
return response()->json([
'message' => 'Your address has been created successfully.',
'data' => new CustomerAddressResource($customerAddress)
]);
}
/**
* Update the specified resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function update()
{
$customer = auth($this->guard)->user();
request()->merge(['address1' => implode(PHP_EOL, array_filter(request()->input('address1')))]);
$this->validate(request(), [
'address1' => 'string|required',
'country' => 'string|required',
'state' => 'string|required',
'city' => 'string|required',
'postcode' => 'required',
'phone' => 'required'
]);
$this->customerAddressRepository->update(request()->all(), request()->input('id'));
return response()->json([
'message' => 'Your address has been updated successfully.',
'data' => new CustomerAddressResource($this->customerAddressRepository->find(request()->input('id')))
]);
}
}

View File

@ -0,0 +1,215 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Event;
use Webkul\Checkout\Repositories\CartRepository;
use Webkul\Checkout\Repositories\CartItemRepository;
use Webkul\API\Http\Resources\Checkout\Cart as CartResource;
use Cart;
/**
* Cart controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CartController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* CartRepository object
*
* @var Object
*/
protected $cartRepository;
/**
* CartItemRepository object
*
* @var Object
*/
protected $cartItemRepository;
/**
* Controller instance
*
* @param Webkul\Checkout\Repositories\CartRepository $cartRepository
* @param Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository
*/
public function __construct(
CartRepository $cartRepository,
CartItemRepository $cartItemRepository
)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
// $this->middleware('auth:' . $this->guard);
$this->_config = request('_config');
$this->cartRepository = $cartRepository;
$this->cartItemRepository = $cartItemRepository;
}
/**
* Get customer cart
*
* @return \Illuminate\Http\Response
*/
public function get()
{
$customer = auth($this->guard)->user();
$cart = Cart::getCart();
return response()->json([
'data' => $cart ? new CartResource($cart) : null
]);
}
/**
* Store a newly created resource in storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function store($id)
{
Event::fire('checkout.cart.item.add.before', $id);
$result = Cart::add($id, request()->except('_token'));
if (! $result) {
$message = session()->get('warning') ?? session()->get('error');
return response()->json([
'error' => session()->get('warning')
], 400);
}
Event::fire('checkout.cart.item.add.after', $result);
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'message' => 'Product added to cart successfully.',
'data' => $cart ? new CartResource($cart) : null
]);
}
/**
* Update the specified resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function update()
{
foreach (request()->get('qty') as$qty) {
if ($qty <= 0) {
return response()->json([
'message' => trans('shop::app.checkout.cart.quantity.illegal')
], 401);
}
}
foreach (request()->get('qty') as $itemId => $qty) {
$item = $this->cartItemRepository->findOneByField('id', $itemId);
Event::fire('checkout.cart.item.update.before', $itemId);
Cart::updateItem($item->product_id, ['quantity' => $qty], $itemId);
Event::fire('checkout.cart.item.update.after', $item);
}
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'message' => 'Cart updated successfully.',
'data' => $cart ? new CartResource($cart) : null
]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\Response
*/
public function destroy()
{
Event::fire('checkout.cart.delete.before');
Cart::deActivateCart();
Event::fire('checkout.cart.delete.after');
$cart = Cart::getCart();
return response()->json([
'message' => 'Cart removed successfully.',
'data' => $cart ? new CartResource($cart) : null
]);
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroyItem($id)
{
Event::fire('checkout.cart.item.delete.before', $id);
Cart::removeItem($id);
Event::fire('checkout.cart.item.delete.after', $id);
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'message' => 'Cart removed successfully.',
'data' => $cart ? new CartResource($cart) : null
]);
}
/**
* Function to move a already added product to wishlist
* will run only on customer authentication.
*
* @param instance cartItem $id
*/
public function moveToWishlist($id)
{
Event::fire('checkout.cart.item.move-to-wishlist.before', $id);
Cart::moveToWishlist($id);
Event::fire('checkout.cart.item.move-to-wishlist.after', $id);
Cart::collectTotals();
$cart = Cart::getCart();
return response()->json([
'message' => 'Cart item moved to wishlist successfully.',
'data' => $cart ? new CartResource($cart) : null
]);
}
}

View File

@ -3,7 +3,6 @@
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Category\Repositories\CategoryRepository;
use Webkul\API\Http\Resources\Catalog\Category as CategoryResource;

View File

@ -0,0 +1,220 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Event;
use Webkul\Checkout\Repositories\CartRepository;
use Webkul\Checkout\Repositories\CartItemRepository;
use Webkul\Shipping\Facades\Shipping;
use Webkul\Payment\Facades\Payment;
use Webkul\API\Http\Resources\Checkout\Cart as CartResource;
use Webkul\API\Http\Resources\Checkout\CartShippingRate as CartShippingRateResource;
use Webkul\API\Http\Resources\Sales\Order as OrderResource;
use Webkul\Checkout\Http\Requests\CustomerAddressForm;
use Webkul\Sales\Repositories\OrderRepository;
use Cart;
/**
* Checkout controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CheckoutController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* CartRepository object
*
* @var Object
*/
protected $cartRepository;
/**
* CartItemRepository object
*
* @var Object
*/
protected $cartItemRepository;
/**
* Controller instance
*
* @param Webkul\Checkout\Repositories\CartRepository $cartRepository
* @param Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository
* @param Webkul\Sales\Repositories\OrderRepository $orderRepository
*/
public function __construct(
CartRepository $cartRepository,
CartItemRepository $cartItemRepository,
OrderRepository $orderRepository
)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
// $this->middleware('auth:' . $this->guard);
$this->_config = request('_config');
$this->cartRepository = $cartRepository;
$this->cartItemRepository = $cartItemRepository;
$this->orderRepository = $orderRepository;
}
/**
* Saves customer address.
*
* @param \Webkul\Checkout\Http\Requests\CustomerAddressForm $request
* @return \Illuminate\Http\Response
*/
public function saveAddress(CustomerAddressForm $request)
{
$data = request()->all();
$data['billing']['address1'] = implode(PHP_EOL, array_filter($data['billing']['address1']));
$data['shipping']['address1'] = implode(PHP_EOL, array_filter($data['shipping']['address1']));
if (isset($data['billing']['id']) && str_contains($data['billing']['id'], 'address_')) {
unset($data['billing']['id']);
unset($data['billing']['address_id']);
}
if (isset($data['shipping']['id']) && str_contains($data['shipping']['id'], 'address_')) {
unset($data['shipping']['id']);
unset($data['shipping']['address_id']);
}
if (Cart::hasError() || ! Cart::saveCustomerAddress($data) || ! Shipping::collectRates())
abort(400);
$rates = [];
foreach (Shipping::getGroupedAllShippingRates() as $code => $shippingMethod) {
$rates[] = [
'carrier_title' => $shippingMethod['carrier_title'],
'rates' => CartShippingRateResource::collection(collect($shippingMethod['rates']))
];
}
Cart::collectTotals();
return response()->json([
'data' => [
'rates' => $rates,
'cart' => new CartResource(Cart::getCart())
]
]);
}
/**
* Saves shipping method.
*
* @return \Illuminate\Http\Response
*/
public function saveShipping()
{
$shippingMethod = request()->get('shipping_method');
if (Cart::hasError() || !$shippingMethod || ! Cart::saveShippingMethod($shippingMethod))
abort(400);
Cart::collectTotals();
return response()->json([
'data' => [
'methods' => Payment::getPaymentMethods(),
'cart' => new CartResource(Cart::getCart())
]
]);
}
/**
* Saves payment method.
*
* @return \Illuminate\Http\Response
*/
public function savePayment()
{
$payment = request()->get('payment');
if (Cart::hasError() || ! $payment || ! Cart::savePaymentMethod($payment))
abort(400);
return response()->json([
'data' => [
'cart' => new CartResource(Cart::getCart())
]
]);
}
/**
* Saves order.
*
* @return \Illuminate\Http\Response
*/
public function saveOrder()
{
if (Cart::hasError())
abort(400);
Cart::collectTotals();
$this->validateOrder();
$cart = Cart::getCart();
if ($redirectUrl = Payment::getRedirectUrl($cart)) {
return response()->json([
'success' => true,
'redirect_url' => $redirectUrl
]);
}
$order = $this->orderRepository->create(Cart::prepareDataForOrder());
Cart::deActivateCart();
return response()->json([
'success' => true,
'order' => new OrderResource($order),
]);
}
/**
* Validate order before creation
*
* @return mixed
*/
public function validateOrder()
{
$cart = Cart::getCart();
if (! $cart->shipping_address) {
throw new \Exception(trans('Please check shipping address.'));
}
if (! $cart->billing_address) {
throw new \Exception(trans('Please check billing address.'));
}
if (! $cart->selected_shipping_rate) {
throw new \Exception(trans('Please specify shipping method.'));
}
if (! $cart->payment) {
throw new \Exception(trans('Please specify payment method.'));
}
}
}

View File

@ -3,7 +3,6 @@
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
/**
* Core controller
@ -13,6 +12,36 @@ use Illuminate\Http\Response;
*/
class CoreController extends Controller
{
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function getConfig()
{
$configValues = [];
foreach (explode(',', request()->input('_config')) as $config) {
$configValues[$config] = core()->getConfigData($config);
}
return response()->json([
'data' => $configValues
]);
}
/**
* Returns a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function getCountryStateGroup()
{
return response()->json([
'data' => core()->groupedStatesByCountries()
]);
}
/**
* Returns a listing of the resource.
*

View File

@ -0,0 +1,73 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Event;
use Webkul\Customer\Repositories\CustomerRepository;
/**
* Customer controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CustomerController extends Controller
{
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* Repository object
*
* @var array
*/
protected $customerRepository;
/**
* @param CustomerRepository object $customer
*/
public function __construct(CustomerRepository $customerRepository)
{
$this->_config = request('_config');
$this->customerRepository = $customerRepository;
}
/**
* Method to store user's sign up form data to DB.
*
* @return Mixed
*/
public function create()
{
request()->validate([
'first_name' => 'required',
'last_name' => 'required',
'email' => 'email|required|unique:customers,email',
'password' => 'confirmed|min:6|required'
]);
$data = request()->input();
$data = array_merge($data, [
'password' => bcrypt($data['password']),
'channel_id' => core()->getCurrentChannel()->id,
'is_verified' => 1,
'customer_group_id' => 1
]);
Event::fire('customer.registration.before');
$customer = $this->customerRepository->create($data);
Event::fire('customer.registration.after', $customer);
return response()->json([
'message' => 'Your account has been created successfully.'
]);
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Support\Facades\Password;
/**
* Forgot Password controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ForgotPasswordController extends Controller
{
use SendsPasswordResetEmails;
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function store()
{
$this->validate(request(), [
'email' => 'required|email'
]);
$response = $this->broker()->sendResetLink(request(['email']));
if ($response == Password::RESET_LINK_SENT) {
return response()->json([
'message' => trans($response)
]);
}
return response()->json([
'error' => trans($response)
]);
}
/**
* Get the broker to be used during password reset.
*
* @return \Illuminate\Contracts\Auth\PasswordBroker
*/
public function broker()
{
return Password::broker('customers');
}
}

View File

@ -30,8 +30,6 @@ class ProductController extends Controller
*/
public function __construct(ProductRepository $productRepository)
{
// $this->middleware('auth:api');
$this->productRepository = $productRepository;
}
@ -42,7 +40,7 @@ class ProductController extends Controller
*/
public function index()
{
return ProductResource::collection($this->productRepository->getAll());
return ProductResource::collection($this->productRepository->getAll(request()->input('category_id')));
}
/**
@ -56,4 +54,28 @@ class ProductController extends Controller
$this->productRepository->findOrFail($id)
);
}
/**
* Returns product's additional information.
*
* @return \Illuminate\Http\Response
*/
public function additionalInformation($id)
{
return response()->json([
'data' => app('Webkul\Product\Helpers\View')->getAdditionalData($this->productRepository->findOrFail($id))
]);
}
/**
* Returns product's additional information.
*
* @return \Illuminate\Http\Response
*/
public function configurableConfig($id)
{
return response()->json([
'data' => app('Webkul\Product\Helpers\ConfigurableOption')->getConfigurationConfig($this->productRepository->findOrFail($id))
]);
}
}

View File

@ -3,7 +3,6 @@
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
/**
* Resource Controller
@ -13,6 +12,13 @@ use Illuminate\Http\Response;
*/
class ResourceController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* Contains route related configuration
*
@ -34,10 +40,17 @@ class ResourceController extends Controller
*/
public function __construct()
{
// $this->middleware('auth:api');
$this->guard = request()->has('token') ? 'api' : 'customer';
$this->_config = request('_config');
if (isset($this->_config['authorization_required']) && $this->_config['authorization_required']) {
auth()->setDefaultDriver($this->guard);
$this->middleware('auth:' . $this->guard);
}
$this->repository = app($this->_config['repository']);
}
@ -49,12 +62,14 @@ class ResourceController extends Controller
public function index()
{
$query = $this->repository->scopeQuery(function($query) {
foreach (request()->except(['page', 'limit', 'pagination', 'sort', 'order']) as $input => $value) {
$query = $query->where($input, $value);
foreach (request()->except(['page', 'limit', 'pagination', 'sort', 'order', 'token']) as $input => $value) {
$query = $query->whereIn($input, array_map('trim', explode(',', $value)));
}
if ($sort = request()->input('sort')) {
$query = $query->orderBy($sort, request()->input('order') ?? 'desc');
} else {
$query = $query->orderBy('id', 'desc');
}
return $query;
@ -80,4 +95,20 @@ class ResourceController extends Controller
$this->repository->findOrFail($id)
);
}
/**
* Delete's a individual resource.
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$wishlistProduct = $this->repository->findOrFail($id);
$this->repository->delete($id);
return response()->json([
'message' => 'Item removed successfully.'
]);
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Http\Request;
use Webkul\Product\Repositories\ProductReviewRepository;
use Webkul\API\Http\Resources\Catalog\ProductReview as ProductReviewResource;
/**
* Review controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class ReviewController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* ProductReviewRepository object
*
* @var array
*/
protected $reviewRepository;
/**
* Controller instance
*
* @param Webkul\Product\Repositories\ProductReviewRepository $reviewRepository
*/
public function __construct(ProductReviewRepository $reviewRepository)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
$this->reviewRepository = $reviewRepository;
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request, $id)
{
$customer = auth($this->guard)->user();
$this->validate(request(), [
'comment' => 'required',
'rating' => 'required|numeric|min:1|max:5',
'title' => 'required',
]);
$data = array_merge(request()->all(), [
'customer_id' => $customer ? $customer->id : null,
'name' => $customer ? $customer->name : request()->input('name'),
'status' => 'pending',
'product_id' => $id
]);
$productReview = $this->reviewRepository->create($data);
return response()->json([
'message' => 'Your review submitted successfully.',
'data' => new ProductReviewResource($this->reviewRepository->find($productReview->id))
]);
}
}

View File

@ -0,0 +1,145 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Event;
use Webkul\Customer\Repositories\CustomerRepository;
use Webkul\API\Http\Resources\Customer\Customer as CustomerResource;
/**
* Session controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class SessionController extends Controller
{
/**
* Contains current guard
*
* @var array
*/
protected $guard;
/**
* Contains route related configuration
*
* @var array
*/
protected $_config;
/**
* Controller instance
*
* @param Webkul\Customer\Repositories\CustomerRepository $customerRepository
*/
public function __construct(CustomerRepository $customerRepository)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
$this->middleware('auth:' . $this->guard, ['only' => ['get', 'update', 'destroy']]);
$this->_config = request('_config');
$this->customerRepository = $customerRepository;
}
/**
* Method to store user's sign up form data to DB.
*
* @return Mixed
*/
public function create()
{
request()->validate([
'email' => 'required|email',
'password' => 'required'
]);
$jwtToken = null;
if (! $jwtToken = auth()->guard($this->guard)->attempt(request()->only('email', 'password'))) {
return response()->json([
'error' => 'Invalid Email or Password',
], 401);
}
Event::fire('customer.after.login', request()->input('email'));
$customer = auth($this->guard)->user();
return response()->json([
'token' => $jwtToken,
'message' => 'Logged in successfully.',
'data' => new CustomerResource($customer)
]);
}
/**
* Get details for current logged in customer
*
* @return \Illuminate\Http\Response
*/
public function get()
{
$customer = auth($this->guard)->user();
return response()->json([
'data' => new CustomerResource($customer)
]);
}
/**
* Update the specified resource in storage.
*
* @return \Illuminate\Http\Response
*/
public function update()
{
$customer = auth($this->guard)->user();
$this->validate(request(), [
'first_name' => 'required',
'last_name' => 'required',
'gender' => 'required',
'date_of_birth' => 'nullable|date|before:today',
'email' => 'email|unique:customers,email,' . $customer->id,
'password' => 'confirmed|min:6'
]);
$data = request()->all();
if (! $data['date_of_birth']) {
unset($data['date_of_birth']);
}
if (!isset($data['password']) || ! $data['password']) {
unset($data['password']);
} else {
$data['password'] = bcrypt($data['password']);
}
$this->customerRepository->update($data, $customer->id);
return response()->json([
'message' => 'Your account has been created successfully.',
'data' => new CustomerResource($this->customerRepository->find($customer->id))
]);
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\Response
*/
public function destroy()
{
auth()->guard($this->guard)->logout();
return response()->json([
'message' => 'Logged out successfully.',
]);
}
}

View File

@ -0,0 +1,135 @@
<?php
namespace Webkul\API\Http\Controllers\Shop;
use Illuminate\Support\Facades\Event;
use Webkul\Customer\Repositories\WishlistRepository;
use Webkul\Product\Repositories\ProductRepository;
use Webkul\API\Http\Resources\Customer\Wishlist as WishlistResource;
use Cart;
/**
* Wishlist controller
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class WishlistController extends Controller
{
/**
* WishlistRepository object
*
* @var object
*/
protected $wishlistRepository;
/**
* ProductRepository object
*
* @var object
*/
protected $productRepository;
/**
* @param Webkul\Customer\Repositories\WishlistRepository $wishlistRepository
* @param Webkul\Product\Repositories\ProductRepository $productRepository
*/
public function __construct(
WishlistRepository $wishlistRepository,
ProductRepository $productRepository
)
{
$this->guard = request()->has('token') ? 'api' : 'customer';
auth()->setDefaultDriver($this->guard);
$this->middleware('auth:' . $this->guard);
$this->wishlistRepository = $wishlistRepository;
$this->productRepository = $productRepository;
}
/**
* Function to add item to the wishlist.
*
* @param integer $id
* @return \Illuminate\Http\Response
*/
public function create($id)
{
$product = $this->productRepository->findOrFail($id);
$customer = auth()->guard($this->guard)->user();
$wishlistItem = $this->wishlistRepository->findOneWhere([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $id,
'customer_id' => $customer->id
]);
if (! $wishlistItem) {
$wishlistItem = $this->wishlistRepository->create([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $id,
'customer_id' => $customer->id
]);
return response()->json([
'data' => new WishlistResource($wishlistItem),
'message' => trans('customer::app.wishlist.success')
]);
} else {
$this->wishlistRepository->delete($wishlistItem->id);
return response()->json([
'data' => null,
'message' => 'Item removed from wishlist successfully.'
]);
}
}
/**
* Move product from wishlist to cart.
*
* @param integer $id
* @return \Illuminate\Http\Response
*/
public function moveToCart($id)
{
$wishlistItem = $this->wishlistRepository->findOrFail($id);
if ($wishlistItem->customer_id != auth()->guard($this->guard)->user()->id)
return response()->json([
'message' => trans('shop::app.security-warning')
], 400);
$result = Cart::moveToCart($wishlistItem);
if ($result == 1) {
if ($wishlistItem->delete()) {
Cart::collectTotals();
return response()->json([
'data' => 1,
'message' => trans('shop::app.wishlist.moved')
]);
} else {
return response()->json([
'data' => 1,
'error' => trans('shop::app.wishlist.move-error')
], 400);
}
} else if ($result == 0) {
return response()->json([
'data' => 0,
'error' => trans('shop::app.wishlist.error')
], 400);
} else if ($result == -1) {
return response()->json([
'data' => -1,
'error' => trans('shop::app.checkout.cart.add-config-warning')
], 400);
}
}
}

View File

@ -17,6 +17,7 @@ class Attribute extends JsonResource
return [
'id' => $this->id,
'code' => $this->code,
'type' => $this->type,
'name' => $this->name,
'swatch_type' => $this->swatch_type,
'options' => AttributeOption::collection($this->options),

View File

@ -19,6 +19,7 @@ class Category extends JsonResource
'code' => $this->code,
'name' => $this->name,
'slug' => $this->slug,
'display_mode' => $this->display_mode,
'description' => $this->description,
'meta_title' => $this->meta_title,
'meta_description' => $this->meta_description,

View File

@ -17,6 +17,8 @@ class Product extends JsonResource
$this->productImageHelper = app('Webkul\Product\Helpers\ProductImage');
$this->productReviewHelper = app('Webkul\Product\Helpers\Review');
parent::__construct($resource);
}
@ -34,14 +36,16 @@ class Product extends JsonResource
'id' => $product->id,
'type' => $product->type,
'name' => $this->name,
'price' => $this->price,
'formated_price' => core()->currency($this->price),
'url_key' => $this->url_key,
'price' => $product->type == 'configurable' ? $this->productPriceHelper->getVariantMinPrice($product) : $this->price,
'formated_price' => $product->type == 'configurable' ? core()->currency($this->productPriceHelper->getVariantMinPrice($product)) : core()->currency($this->price),
'short_description' => $this->short_description,
'description' => $this->description,
'sku' => $this->sku,
'images' => ProductImage::collection($product->images),
'base_image' => $this->productImageHelper->getProductBaseImage($product),
'variants' => Self::collection($this->variants),
'in_stock' => $product->haveSufficientQuantity(1),
'in_stock' => $product->type == 'configurable' ? 1 : $product->haveSufficientQuantity(1),
$this->mergeWhen($product->type == 'configurable', [
'super_attributes' => Attribute::collection($product->super_attributes),
]),
@ -53,6 +57,13 @@ class Product extends JsonResource
$this->productPriceHelper->haveSpecialPrice($product),
core()->currency($this->productPriceHelper->getSpecialPrice($product))
),
'reviews' => [
'total' => $total = $this->productReviewHelper->getTotalReviews($product),
'total_rating' => $total ? $this->productReviewHelper->getTotalRating($product) : 0,
'average_rating' => $total ? $this->productReviewHelper->getAverageRating($product) : 0,
'percentage' => $total ? json_encode($this->productReviewHelper->getPercentageRating($product)) : [],
],
'is_saved' => false,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];

View File

@ -18,6 +18,7 @@ class ProductImage extends JsonResource
'id' => $this->id,
'path' => $this->path,
'url' => $this->url,
'original_image_url' => $this->url,
'small_image_url' => url('cache/small/' . $this->path),
'medium_image_url' => url('cache/medium/' . $this->path),
'large_image_url' => url('cache/large/' . $this->path)

View File

@ -18,7 +18,7 @@ class ProductReview extends JsonResource
return [
'id' => $this->id,
'title' => $this->title,
'rating' => $this->rating,
'rating' => number_format($this->rating, 1, '.', ''),
'comment' => $this->comment,
'name' => $this->name,
'status' => $this->status,

View File

@ -0,0 +1,65 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Core\Channel as ChannelResource;
use Webkul\API\Http\Resources\Customer\Customer as CustomerResource;
class Cart extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'customer_email' => $this->customer_email,
'customer_first_name' => $this->customer_first_name,
'customer_last_name' => $this->customer_last_name,
'shipping_method' => $this->shipping_method,
'coupon_code' => $this->coupon_code,
'is_gift' => $this->is_gift,
'items_count' => $this->items_count,
'items_qty' => $this->items_qty,
'exchange_rate' => $this->exchange_rate,
'global_currency_code' => $this->global_currency_code,
'base_currency_code' => $this->base_currency_code,
'channel_currency_code' => $this->channel_currency_code,
'cart_currency_code' => $this->cart_currency_code,
'grand_total' => $this->grand_total,
'formated_grand_total' => core()->formatPrice($this->grand_total, $this->cart_currency_code),
'base_grand_total' => $this->base_grand_total,
'formated_base_grand_total' => core()->formatBasePrice($this->base_grand_total),
'sub_total' => $this->sub_total,
'formated_sub_total' => core()->formatPrice($this->sub_total, $this->cart_currency_code),
'base_sub_total' => $this->base_sub_total,
'formated_base_sub_total' => core()->formatBasePrice($this->base_sub_total),
'tax_total' => $this->tax_total,
'formated_tax_total' => core()->formatPrice($this->tax_total, $this->cart_currency_code),
'base_tax_total' => $this->base_tax_total,
'formated_base_tax_total' => core()->formatBasePrice($this->base_tax_total),
'discount' => $this->discount,
'formated_discount' => core()->formatPrice($this->discount, $this->cart_currency_code),
'base_discount' => $this->base_discount,
'formated_base_discount' => core()->formatBasePrice($this->base_discount),
'checkout_method' => $this->checkout_method,
'is_guest' => $this->is_guest,
'is_active' => $this->is_active,
'conversion_time' => $this->conversion_time,
'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)),
'channel' => $this->when($this->channel_id, new ChannelResource($this->channel)),
'items' => CartItem::collection($this->items),
'selected_shipping_rate' => new CartShippingRate($this->selected_shipping_rate),
'payment' => new CartPayment($this->payment),
'billing_address' => new CartAddress($this->billing_address),
'shipping_address' => new CartAddress($this->shipping_address),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
class CartAddress extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'name' => $this->name,
'email' => $this->email,
'address1' => explode(PHP_EOL, $this->address1),
'country' => $this->country,
'country_name' => country()->name($this->country),
'state' => $this->state,
'city' => $this->city,
'postcode' => $this->postcode,
'phone' => $this->phone,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -0,0 +1,57 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Catalog\Product as ProductResource;
class CartItem extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'quantity' => $this->quantity,
'sku' => $this->sku,
'type' => $this->type,
'name' => $this->name,
'coupon_code' => $this->coupon_code,
'weight' => $this->weight,
'total_weight' => $this->total_weight,
'base_total_weight' => $this->base_total_weight,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $this->cart->cart_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'custom_price' => $this->custom_price,
'formated_custom_price' => core()->formatPrice($this->custom_price, $this->cart->cart_currency_code),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->total, $this->cart->cart_currency_code),
'base_total' => $this->base_total,
'formated_base_total' => core()->formatBasePrice($this->base_total),
'tax_percent' => $this->tax_percent,
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->cart->cart_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'discount_percent' => $this->discount_percent,
'discount_amount' => $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->cart->cart_currency_code),
'base_discount_amount' => $this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),
'child' => new self($this->child),
'product' => $this->when($this->product_id, new ProductResource($this->product)),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
class CartPayment extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'method' => $this->method,
'method_title' => core()->getConfigData('sales.paymentmethods.' . $this->method . '.title'),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
];
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace Webkul\API\Http\Resources\Checkout;
use Illuminate\Http\Resources\Json\JsonResource;
use Cart;
class CartShippingRate extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
$cart = Cart::getCart();
return [
'id' => $this->id,
'carrier' => $this->carrier,
'carrier_title' => $this->carrier_title,
'method' => $this->method,
'method_title' => $this->method_title,
'method_description' => $this->method_description,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $cart->cart_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at
];
}
}

View File

@ -33,6 +33,7 @@ class Channel extends JsonResource
'favicon_url' => $this->favicon_url,
'default_locale' => $this->when($this->default_locale_id, new LocaleResource($this->default_locale)),
'base_currency' => $this->when($this->default_currency_id, new CurrencyResource($this->default_currency)),
'root_category_id' => $this->root_category_id,
'root_category' => $this->when($this->root_category_id, new CategoryResource($this->root_category)),
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,

View File

@ -0,0 +1,23 @@
<?php
namespace Webkul\API\Http\Resources\Core;
use Illuminate\Http\Resources\Json\JsonResource;
class Country extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'code' => $this->code,
'name' => $this->name
];
}
}

View File

@ -16,9 +16,9 @@ class CustomerAddress extends JsonResource
{
return [
'id' => $this->id,
'address1' => $this->address1,
'address2' => $this->address2,
'address1' => explode(PHP_EOL, $this->address1),
'country' => $this->country,
'country_name' => country()->name($this->country),
'state' => $this->state,
'city' => $this->city,
'postcode' => $this->postcode,

View File

@ -23,18 +23,29 @@ class Invoice extends JsonResource
'channel_currency_code' => $this->channel_currency_code,
'order_currency_code' => $this->order_currency_code,
'sub_total' => $this->sub_total,
'formated_sub_total' => core()->formatPrice($this->sub_total, $this->order_currency_code),
'base_sub_total' => $this->base_sub_total,
'formated_base_sub_total' => core()->formatBasePrice($this->base_sub_total),
'grand_total' => $this->grand_total,
'formated_grand_total' => core()->formatPrice($this->grand_total, $this->order_currency_code),
'base_grand_total' => $this->base_grand_total,
'formated_base_grand_total' => core()->formatBasePrice($this->base_grand_total),
'shipping_amount' => $this->shipping_amount,
'formated_shipping_amount' => core()->formatPrice($this->shipping_amount, $this->order_currency_code),
'base_shipping_amount' => $this->base_shipping_amount,
'formated_base_shipping_amount' => core()->formatBasePrice($this->base_shipping_amount),
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->order_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'discount_amount' => $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->order_currency_code),
'base_discount_amount' => $this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'order_address' => new OrderAddress($this->address),
'transaction_id' => $this->transaction_id,
'items' => InvoiceItem::collection($this->items),
'created_at' => $this->created_at
];
}
}

View File

@ -17,16 +17,27 @@ class InvoiceItem extends JsonResource
return [
'id' => $this->id,
'name' => $this->name,
// 'product' => $this->when($this->product, new ProductResource($this->product)),
'description' => $this->description,
'sku' => $this->sku,
'description' => $this->description,
'qty' => $this->qty,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $this->invoice->order_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->total, $this->invoice->order_currency_code),
'base_total' => $this->base_total,
'formated_base_total' => core()->formatBasePrice($this->base_total),
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->invoice->order_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'grand_total' => $this->total + $this->tax_amount,
'formated_grand_total' => core()->formatPrice($this->total + $this->tax_amount, $this->invoice->order_currency_code),
'base_grand_total' => $this->base_total + $this->base_tax_amount,
'formated_base_grand_total' => core()->formatBasePrice($this->base_total + $this->base_tax_amount),
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),

View File

@ -19,6 +19,7 @@ class Order extends JsonResource
return [
'id' => $this->id,
'status' => $this->status,
'status_label' => $this->status_label,
'channel_name' => $this->channel_name,
'is_guest' => $this->is_guest,
'customer_email' => $this->customer_email,
@ -26,6 +27,7 @@ class Order extends JsonResource
'customer_last_name' => $this->customer_last_name,
'shipping_method' => $this->shipping_method,
'shipping_title' => $this->shipping_title,
'payment_title' => core()->getConfigData('sales.paymentmethods.' . $this->payment->method . '.title'),
'shipping_description' => $this->shipping_description,
'coupon_code' => $this->coupon_code,
'is_gift' => $this->is_gift,
@ -35,37 +37,68 @@ class Order extends JsonResource
'channel_currency_code' => $this->channel_currency_code,
'order_currency_code' => $this->order_currency_code,
'grand_total' => $this->grand_total,
'formated_grand_total' => core()->formatPrice($this->grand_total, $this->order_currency_code),
'base_grand_total' => $this->base_grand_total,
'formated_base_grand_total' => core()->formatBasePrice($this->base_grand_total),
'grand_total_invoiced' => $this->grand_total_invoiced,
'formated_grand_total_invoiced' => core()->formatPrice($this->grand_total_invoiced, $this->order_currency_code),
'base_grand_total_invoiced' => $this->base_grand_total_invoiced,
'formated_base_grand_total_invoiced' => core()->formatBasePrice($this->base_grand_total_invoiced),
'grand_total_refunded' => $this->grand_total_refunded,
'formated_grand_total_refunded' => core()->formatPrice($this->grand_total_refunded, $this->order_currency_code),
'base_grand_total_refunded' => $this->base_grand_total_refunded,
'formated_base_grand_total_refunded' => core()->formatBasePrice($this->base_grand_total_refunded),
'sub_total' => $this->sub_total,
'formated_sub_total' => core()->formatPrice($this->sub_total, $this->order_currency_code),
'base_sub_total' => $this->base_sub_total,
'formated_base_sub_total' => core()->formatBasePrice($this->base_sub_total),
'sub_total_invoiced' => $this->sub_total_invoiced,
'formated_sub_total_invoiced' => core()->formatPrice($this->sub_total_invoiced, $this->order_currency_code),
'base_sub_total_invoiced' => $this->base_sub_total_invoiced,
'formated_base_sub_total_invoiced' => core()->formatBasePrice($this->base_sub_total_invoiced),
'sub_total_refunded' => $this->sub_total_refunded,
'formated_sub_total_refunded' => core()->formatPrice($this->sub_total_refunded, $this->order_currency_code),
'discount_percent' => $this->discount_percent,
'discount_amount' => $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->order_currency_code),
'base_discount_amount' => $this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'discount_invoiced' => $this->discount_invoiced,
'formated_discount_invoiced' => core()->formatPrice($this->discount_invoiced, $this->order_currency_code),
'base_discount_invoiced' => $this->base_discount_invoiced,
'formated_base_discount_invoiced' => core()->formatBasePrice($this->base_discount_invoiced),
'discount_refunded' => $this->discount_refunded,
'formated_discount_refunded' => core()->formatPrice($this->discount_refunded, $this->order_currency_code),
'base_discount_refunded' => $this->base_discount_refunded,
'formated_base_discount_refunded' => core()->formatBasePrice($this->base_discount_refunded),
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->order_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'tax_amount_invoiced' => $this->tax_amount_invoiced,
'formated_tax_amount_invoiced' => core()->formatPrice($this->tax_amount_invoiced, $this->order_currency_code),
'base_tax_amount_invoiced' => $this->base_tax_amount_invoiced,
'formated_base_tax_amount_invoiced' => core()->formatBasePrice($this->base_tax_amount_invoiced),
'tax_amount_refunded' => $this->tax_amount_refunded,
'formated_tax_amount_refunded' => core()->formatPrice($this->tax_amount_refunded, $this->order_currency_code),
'base_tax_amount_refunded' => $this->base_tax_amount_refunded,
'formated_base_tax_amount_refunded' => core()->formatBasePrice($this->base_tax_amount_refunded),
'shipping_amount' => $this->shipping_amount,
'formated_shipping_amount' => core()->formatPrice($this->shipping_amount, $this->order_currency_code),
'base_shipping_amount' => $this->base_shipping_amount,
'formated_base_shipping_amount' => core()->formatBasePrice($this->base_shipping_amount),
'shipping_invoiced' => $this->shipping_invoiced,
'formated_shipping_invoiced' => core()->formatPrice($this->shipping_invoiced, $this->order_currency_code),
'base_shipping_invoiced' => $this->base_shipping_invoiced,
'formated_base_shipping_invoiced' => core()->formatBasePrice($this->base_shipping_invoiced),
'shipping_refunded' => $this->shipping_refunded,
'formated_shipping_refunded' => core()->formatPrice($this->shipping_refunded, $this->order_currency_code),
'base_shipping_refunded' => $this->base_shipping_refunded,
'formated_base_shipping_refunded' => core()->formatBasePrice($this->base_shipping_refunded),
'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)),
'channel' => $this->when($this->channel_id, new ChannelResource($this->channel)),
'shipping_address' => new OrderAddress($this->shipping_address),
'billing_address' => new OrderAddress($this->billing_address),
'updated_at' => $this->updated_at,
'items' => OrderItem::collection($this->items),
'invoices' => Invoice::collection($this->invoices),

View File

@ -19,9 +19,9 @@ class OrderAddress extends JsonResource
'email' => $this->email,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'address1' => $this->address1,
'address2' => $this->address2,
'address1' => explode(PHP_EOL, $this->address1),
'country' => $this->country,
'country_name' => country()->name($this->country),
'state' => $this->state,
'city' => $this->city,
'postcode' => $this->postcode,

View File

@ -3,6 +3,7 @@
namespace Webkul\API\Http\Resources\Sales;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\API\Http\Resources\Catalog\Product as ProductResource;
class OrderItem extends JsonResource
{
@ -19,35 +20,61 @@ class OrderItem extends JsonResource
'sku' => $this->sku,
'type' => $this->type,
'name' => $this->name,
'product' => $this->when($this->product, new ProductResource($this->product)),
'coupon_code' => $this->coupon_code,
'weight' => $this->weight,
'total_weight' => $this->total_weight,
'qty_ordered' => $this->qty_ordered,
'qty_canceled' => $this->qty_canceled,
'qty_invoiced' => $this->qty_invoiced,
'qty_shipped' => $this->qty_shipped,
'qty_refunded' => $this->qty_refunded,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $this->order->order_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->total, $this->order->order_currency_code),
'base_total' => $this->base_total,
'formated_base_total' => core()->formatBasePrice($this->base_total),
'total_invoiced' => $this->total_invoiced,
'formated_total_invoiced' => core()->formatPrice($this->total_invoiced, $this->order->order_currency_code),
'base_total_invoiced' => $this->base_total_invoiced,
'formated_base_total_invoiced' => core()->formatBasePrice($this->base_total_invoiced),
'amount_refunded' => $this->amount_refunded,
'formated_amount_refunded' => core()->formatPrice($this->amount_refunded, $this->order->order_currency_code),
'base_amount_refunded' => $this->base_amount_refunded,
'formated_base_amount_refunded' => core()->formatBasePrice($this->base_amount_refunded),
'discount_percent' => $this->discount_percent,
'discount_amount' => $this->discount_amount,
'formated_discount_amount' => core()->formatPrice($this->discount_amount, $this->order->order_currency_code),
'base_discount_amount' => $this->base_discount_amount,
'formated_base_discount_amount' => core()->formatBasePrice($this->base_discount_amount),
'discount_invoiced' => $this->discount_invoiced,
'formated_discount_invoiced' => core()->formatPrice($this->discount_invoiced, $this->order->order_currency_code),
'base_discount_invoiced' => $this->base_discount_invoiced,
'formated_base_discount_invoiced' => core()->formatBasePrice($this->base_discount_invoiced),
'discount_refunded' => $this->discount_refunded,
'formated_discount_refunded' => core()->formatPrice($this->discount_refunded, $this->order->order_currency_code),
'base_discount_refunded' => $this->base_discount_refunded,
'formated_base_discount_refunded' => core()->formatBasePrice($this->base_discount_refunded),
'tax_percent' => $this->tax_percent,
'tax_amount' => $this->tax_amount,
'formated_tax_amount' => core()->formatPrice($this->tax_amount, $this->order->order_currency_code),
'base_tax_amount' => $this->base_tax_amount,
'formated_base_tax_amount' => core()->formatBasePrice($this->base_tax_amount),
'tax_amount_invoiced' => $this->tax_amount_invoiced,
'formated_tax_amount_invoiced' => core()->formatPrice($this->tax_amount_invoiced, $this->order->order_currency_code),
'base_tax_amount_invoiced' => $this->base_tax_amount_invoiced,
'formated_base_tax_amount_invoiced' => core()->formatBasePrice($this->base_tax_amount_invoiced),
'tax_amount_refunded' => $this->tax_amount_refunded,
'formated_tax_amount_refunded' => core()->formatPrice($this->tax_amount_refunded, $this->order->order_currency_code),
'base_tax_amount_refunded' => $this->base_tax_amount_refunded,
'formated_base_tax_amount_refunded' => core()->formatBasePrice($this->base_tax_amount_refunded),
'grant_total' => $this->total + $this->tax_amount,
'formated_grant_total' => core()->formatPrice($this->total + $this->tax_amount, $this->order->order_currency_code),
'base_grant_total' => $this->base_total + $this->base_tax_amount,
'formated_base_grant_total' => core()->formatPrice($this->base_total + $this->base_tax_amount, $this->order->order_currency_code),
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true),

View File

@ -22,9 +22,13 @@ class ShipmentItem extends JsonResource
'qty' => $this->qty,
'weight' => $this->weight,
'price' => $this->price,
'formated_price' => core()->formatPrice($this->price, $this->shipment->order->order_currency_code),
'base_price' => $this->base_price,
'formated_base_price' => core()->formatBasePrice($this->base_price),
'total' => $this->total,
'formated_total' => core()->formatPrice($this->total, $this->shipment->order->order_currency_code),
'base_total' => $this->base_total,
'formated_base_total' => core()->formatBasePrice($this->base_total),
'additional' => is_array($this->resource->additional)
? $this->resource->additional
: json_decode($this->resource->additional, true)

View File

@ -2,7 +2,7 @@
Route::group(['prefix' => 'api'], function ($router) {
Route::group(['namespace' => 'Webkul\API\Http\Controllers\Shop', 'middleware' => ['locale', 'currency']], function ($router) {
Route::group(['namespace' => 'Webkul\API\Http\Controllers\Shop', 'middleware' => ['locale', 'theme', 'currency']], function ($router) {
//Currency and Locale switcher
Route::get('switch-currency', 'CoreController@switchCurrency');
@ -15,7 +15,7 @@ Route::group(['prefix' => 'api'], function ($router) {
'resource' => 'Webkul\API\Http\Resources\Catalog\Category'
]);
Route::get('descendants-categories', 'CategoryController@index');
Route::get('descendant-categories', 'CategoryController@index');
Route::get('categories/{id}', 'ResourceController@get')->defaults('_config', [
'repository' => 'Webkul\Category\Repositories\CategoryRepository',
@ -52,6 +52,10 @@ Route::group(['prefix' => 'api'], function ($router) {
Route::get('products/{id}', 'ProductController@get');
Route::get('product-additional-information/{id}', 'ProductController@additionalInformation');
Route::get('product-configurable-config/{id}', 'ProductController@configurableConfig');
//Product Review routes
Route::get('reviews', 'ResourceController@index')->defaults('_config', [
@ -64,6 +68,8 @@ Route::group(['prefix' => 'api'], function ($router) {
'resource' => 'Webkul\API\Http\Resources\Catalog\ProductReview'
]);
Route::post('reviews/{id}/create', 'ReviewController@store');
//Channel routes
Route::get('channels', 'ResourceController@index')->defaults('_config', [
@ -89,6 +95,20 @@ Route::group(['prefix' => 'api'], function ($router) {
]);
//Country routes
Route::get('countries', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Core\Repositories\CountryRepository',
'resource' => 'Webkul\API\Http\Resources\Core\Country'
]);
Route::get('countries/{id}', 'ResourceController@get')->defaults('_config', [
'repository' => 'Webkul\Core\Repositories\CountryRepository',
'resource' => 'Webkul\API\Http\Resources\Core\Country'
]);
Route::get('country-states', 'CoreController@getCountryStateGroup');
//Slider routes
Route::get('sliders', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Core\Repositories\SliderRepository',
@ -112,71 +132,132 @@ Route::group(['prefix' => 'api'], function ($router) {
'resource' => 'Webkul\API\Http\Resources\Core\Currency'
]);
Route::get('config', 'CoreController@getConfig');
//Customer routes
Route::get('customers', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Customer\Repositories\CustomerRepository',
'resource' => 'Webkul\API\Http\Resources\Customer\Customer'
]);
Route::post('customer/login', 'SessionController@create');
Route::post('customer/forgot-password', 'ForgotPasswordController@store');
Route::get('customer/logout', 'SessionController@destroy');
Route::get('customer/get', 'SessionController@get');
Route::put('customer/profile', 'SessionController@update');
Route::post('customer/register', 'CustomerController@create');
Route::get('customers/{id}', 'ResourceController@get')->defaults('_config', [
'repository' => 'Webkul\Customer\Repositories\CustomerRepository',
'resource' => 'Webkul\API\Http\Resources\Customer\Customer'
'resource' => 'Webkul\API\Http\Resources\Customer\Customer',
'authorization_required' => true
]);
//Customer Address routes
Route::get('addresses', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Customer\Repositories\CustomerAddressRepository',
'resource' => 'Webkul\API\Http\Resources\Customer\CustomerAddress'
'resource' => 'Webkul\API\Http\Resources\Customer\CustomerAddress',
'authorization_required' => true
]);
Route::get('addresses/{id}', 'ResourceController@get')->defaults('_config', [
'repository' => 'Webkul\Customer\Repositories\CustomerAddressRepository',
'resource' => 'Webkul\API\Http\Resources\Customer\CustomerAddress'
'resource' => 'Webkul\API\Http\Resources\Customer\CustomerAddress',
'authorization_required' => true
]);
Route::put('addresses/{id}', 'AddressController@update')->defaults('_config', [
'authorization_required' => true
]);
Route::post('addresses/create', 'AddressController@store')->defaults('_config', [
'authorization_required' => true
]);
//Order routes
Route::get('orders', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\OrderRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\Order'
'resource' => 'Webkul\API\Http\Resources\Sales\Order',
'authorization_required' => true
]);
Route::get('orders/{id}', 'ResourceController@get')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\OrderRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\Order'
'resource' => 'Webkul\API\Http\Resources\Sales\Order',
'authorization_required' => true
]);
//Invoice routes
Route::get('invoices', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\InvoiceRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\Invoice'
'resource' => 'Webkul\API\Http\Resources\Sales\Invoice',
'authorization_required' => true
]);
Route::get('invoices/{id}', 'ResourceController@get')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\InvoiceRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\Invoice'
'resource' => 'Webkul\API\Http\Resources\Sales\Invoice',
'authorization_required' => true
]);
//Invoice routes
Route::get('shipments', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\ShipmentRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\Shipment'
'resource' => 'Webkul\API\Http\Resources\Sales\Shipment',
'authorization_required' => true
]);
Route::get('shipments/{id}', 'ResourceController@get')->defaults('_config', [
'repository' => 'Webkul\Sales\Repositories\ShipmentRepository',
'resource' => 'Webkul\API\Http\Resources\Sales\Shipment'
'resource' => 'Webkul\API\Http\Resources\Sales\Shipment',
'authorization_required' => true
]);
//Wishlist routes
Route::get('wishlist', 'ResourceController@index')->defaults('_config', [
'repository' => 'Webkul\Customer\Repositories\WishlistRepository',
'resource' => 'Webkul\API\Http\Resources\Customer\Wishlist'
'resource' => 'Webkul\API\Http\Resources\Customer\Wishlist',
'authorization_required' => true
]);
Route::delete('wishlist/{id}', 'ResourceController@destroy')->defaults('_config', [
'repository' => 'Webkul\Customer\Repositories\WishlistRepository',
'resource' => 'Webkul\API\Http\Resources\Customer\Wishlist',
'authorization_required' => true
]);
Route::get('move-to-cart/{id}', 'WishlistController@moveToCart');
Route::get('wishlist/add/{id}', 'WishlistController@create');
//Checkout routes
Route::group(['prefix' => 'checkout'], function ($router) {
Route::post('cart/add/{id}', 'CartController@store');
Route::get('cart', 'CartController@get');
Route::get('cart/empty', 'CartController@destroy');
Route::put('cart/update', 'CartController@update');
Route::get('cart/remove-item/{id}', 'CartController@destroyItem');
Route::get('cart/move-to-wishlist/{id}', 'CartController@moveToWishlist');
Route::post('save-address', 'CheckoutController@saveAddress');
Route::post('save-shipping', 'CheckoutController@saveShipping');
Route::post('save-payment', 'CheckoutController@savePayment');
Route::post('save-order', 'CheckoutController@saveOrder');
});
});
});

View File

@ -3,6 +3,8 @@
namespace Webkul\API\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Routing\Router;
use Webkul\API\Http\Middleware\JwtMiddleware;
class APIServiceProvider extends ServiceProvider
{
@ -11,7 +13,7 @@ class APIServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot()
public function boot(Router $router)
{
$this->loadRoutesFrom(__DIR__.'/../Http/routes.php');
}

View File

@ -63,5 +63,26 @@ return [
'type' => 'boolean'
]
],
]
], [
'key' => 'general',
'name' => 'admin::app.admin.system.general',
'sort' => 4,
], [
'key' => 'general.content',
'name' => 'admin::app.admin.system.content',
'sort' => 1,
], [
'key' => 'general.content.footer',
'name' => 'admin::app.admin.system.footer',
'sort' => 1,
'fields' => [
[
'name' => 'footer_content',
'title' => 'admin::app.admin.system.footer-content',
'type' => 'text',
'channel_based' => true,
'locale_based' => true
]
]
],
];

View File

@ -638,6 +638,10 @@ Route::group(['middleware' => ['web']], function () {
Route::get('/cart-rule/create', 'Webkul\Discount\Http\Controllers\CartRuleController@create')->defaults('_config', [
'view' => 'admin::promotions.cart-rule.create'
])->name('admin.cart-rule.create');
Route::post('/cart-rule/store', 'Webkul\Discount\Http\Controllers\CartRuleController@store')->defaults('_config', [
'view' => 'admin.cart-rule.index'
])->name('admin.cart-rule.store');
});
});
});

View File

@ -792,6 +792,10 @@ return [
'catalog' => [
'name' => 'Name',
'description' => 'Description',
'apply-percent' => 'Apply as percentage',
'apply-fixed' => 'Apply as fixed Amount',
'adjust-to-percent' => 'Adjust to percentage',
'adjust-to-value' => 'Adjust to discount value'
]
],
@ -905,7 +909,11 @@ return [
'newsletter-subscription' => 'Allow NewsLetter Subscription',
'email' => 'Email Verification',
'email-verification' => 'Allow Email Verification',
'sort_order' => 'Sort Order'
'sort_order' => 'Sort Order',
'general' => 'General',
'footer' => 'Footer',
'content' => 'Content',
'footer-content' => 'Text Value'
]
]
];

View File

@ -326,7 +326,7 @@
inject: ['$validator'],
data() {
data: function() {
return {
optionRowCount: 0,
optionRows: [],
@ -335,7 +335,7 @@
}
},
created () {
created: function () {
var this_this = this;
$(document).ready(function () {
@ -350,7 +350,7 @@
},
methods: {
addOptionRow () {
addOptionRow: function () {
var rowCount = this.optionRowCount++;
var row = {'id': 'option_' + rowCount};
@ -361,20 +361,20 @@
this.optionRows.push(row);
},
removeRow (row) {
removeRow: function (row) {
var index = this.optionRows.indexOf(row)
Vue.delete(this.optionRows, index);
},
adminName (row) {
adminName: function (row) {
return 'options[' + row.id + '][admin_name]';
},
localeInputName (row, locale) {
localeInputName: function (row, locale) {
return 'options[' + row.id + '][' + locale + '][label]';
},
sortOrderName (row) {
sortOrderName: function (row) {
return 'options[' + row.id + '][sort_order]';
}
}

View File

@ -370,7 +370,7 @@
inject: ['$validator'],
data() {
data: function() {
return {
optionRowCount: 0,
optionRows: [],
@ -379,7 +379,7 @@
}
},
created () {
created: function () {
@foreach ($attribute->options as $option)
this.optionRowCount++;
var row = {
@ -410,7 +410,7 @@
},
methods: {
addOptionRow () {
addOptionRow: function () {
var rowCount = this.optionRowCount++;
var row = {'id': 'option_' + rowCount};
@ -421,20 +421,20 @@
this.optionRows.push(row);
},
removeRow (row) {
removeRow: function (row) {
var index = this.optionRows.indexOf(row)
Vue.delete(this.optionRows, index);
},
adminName (row) {
adminName: function (row) {
return 'options[' + row.id + '][admin_name]';
},
localeInputName (row, locale) {
localeInputName: function (row, locale) {
return 'options[' + row.id + '][' + locale + '][label]';
},
sortOrderName (row) {
sortOrderName: function (row) {
return 'options[' + row.id + '][sort_order]';
}
}

View File

@ -101,7 +101,9 @@
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="image" :multiple="false"></image-wrapper>
<span class="control-error" v-if="{!! $errors->has('image.*') !!}">
{{ $errors->first('image.*') }}
@foreach ($errors->get('image.*') as $key => $message)
@php echo str_replace($key, 'Image', $message[0]); @endphp
@endforeach
</span>
</div>
@ -208,13 +210,13 @@
inject: ['$validator'],
data() {
data: function() {
return {
isRequired: true,
}
},
created () {
created: function () {
var this_this = this;
$(document).ready(function () {

View File

@ -114,7 +114,9 @@
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="image" :multiple="false" :images='"{{ $category->image_url }}"'></image-wrapper>
<span class="control-error" v-if="{!! $errors->has('image.*') !!}">
{{ $errors->first('image.*') }}
@foreach ($errors->get('image.*') as $key => $message)
@php echo str_replace($key, 'Image', $message[0]); @endphp
@endforeach
</span>
</div>
@ -220,13 +222,13 @@
inject: ['$validator'],
data() {
data: function() {
return {
isRequired: true,
}
},
created () {
created: function () {
var this_this = this;
$(document).ready(function () {

View File

@ -203,7 +203,7 @@
Vue.component('group-form', {
data() {
data: function () {
return {
group: {
'groupName': '',
@ -217,8 +217,8 @@
template: '#group-form-template',
methods: {
addGroup (formScope) {
this.$validator.validateAll(formScope).then((result) => {
addGroup: function (formScope) {
this.$validator.validateAll(formScope).then(function (result) {
if (result) {
var this_this = this;
@ -250,7 +250,7 @@
});
},
sortGroups () {
sortGroups: function () {
return groups.sort(function(a, b) {
return a.position - b.position;
});
@ -262,30 +262,30 @@
template: '#group-list-template',
data() {
data: function() {
return {
groups: groups,
custom_attributes: custom_attributes
}
},
created () {
this.groups.forEach(function(group) {
group.custom_attributes.forEach(function(attribute) {
var attribute = this.custom_attributes.filter(attributeTemp => attributeTemp.id == attribute.id)
created: function () {
this.groups.forEach(function (group) {
group.custom_attributes.forEach(function (attribute) {
var attribute = this.custom_attributes.filter(function (attributeTemp) {
return attributeTemp.id == attribute.id;
});
if (attribute.length) {
let index = this.custom_attributes.indexOf(attribute[0])
this.custom_attributes.splice(index, 1)
var index = this.custom_attributes.indexOf(attribute[0]);
this.custom_attributes.splice(index, 1);
}
});
});
},
methods: {
removeGroup (group) {
removeGroup: function (group) {
group.custom_attributes.forEach(function(attribute) {
this.custom_attributes.push(attribute);
})
@ -297,9 +297,11 @@
groups.splice(index, 1)
},
addAttributes (groupIndex, attributeIds) {
addAttributes: function (groupIndex, attributeIds) {
attributeIds.forEach(function(attributeId) {
var attribute = this.custom_attributes.filter(attribute => attribute.id == attributeId)
var attribute = this.custom_attributes.filter(function (attribute) {
return attribute.id == attributeId;
});
this.groups[groupIndex].custom_attributes.push(attribute[0]);
@ -309,7 +311,7 @@
})
},
removeAttribute (groupIndex, attribute) {
removeAttribute: function (groupIndex, attribute) {
let index = this.groups[groupIndex].custom_attributes.indexOf(attribute)
this.groups[groupIndex].custom_attributes.splice(index, 1)
@ -319,7 +321,7 @@
this.custom_attributes = this.sortAttributes();
},
sortAttributes () {
sortAttributes: function () {
return this.custom_attributes.sort(function(a, b) {
return a.id - b.id;
});
@ -333,17 +335,17 @@
template: "#group-item-template",
computed: {
groupInputName () {
groupInputName: function () {
return "attribute_groups[group_" + this.index + "]";
}
},
methods: {
removeGroup () {
removeGroup: function () {
this.$emit('onRemoveGroup', this.group)
},
addAttributes (e) {
addAttributes: function (e) {
var attributeIds = [];
$(e.target).prev().find('li input').each(function() {
@ -361,7 +363,7 @@
this.$emit('onAttributeAdd', attributeIds)
},
removeAttribute (attribute) {
removeAttribute: function (attribute) {
this.$emit('onAttributeRemove', attribute)
}
}

View File

@ -202,7 +202,7 @@
Vue.component('group-form', {
data() {
data: function() {
return {
group: {
'groupName': '',
@ -215,8 +215,8 @@
template: '#group-form-template',
methods: {
addGroup (formScope) {
this.$validator.validateAll(formScope).then((result) => {
addGroup: function (formScope) {
this.$validator.validateAll(formScope).then(function(result) {
if (result) {
var this_this = this;
@ -248,7 +248,7 @@
});
},
sortGroups () {
sortGroups: function () {
return groups.sort(function(a, b) {
return a.position - b.position;
});
@ -260,17 +260,19 @@
template: '#group-list-template',
data() {
data: function() {
return {
groups: groups,
custom_attributes: custom_attributes
}
},
created () {
created: function () {
this.groups.forEach(function(group) {
group.custom_attributes.forEach(function(attribute) {
var attribute = this.custom_attributes.filter(attributeTemp => attributeTemp.id == attribute.id)
var attribute = this.custom_attributes.filter(function (attributeTemp) {
return attributeTemp.id == attribute.id;
});
if (attribute.length) {
let index = this.custom_attributes.indexOf(attribute[0])
@ -283,7 +285,7 @@
},
methods: {
removeGroup (group) {
removeGroup: function (group) {
group.custom_attributes.forEach(function(attribute) {
this.custom_attributes.push(attribute);
})
@ -295,9 +297,11 @@
groups.splice(index, 1)
},
addAttributes (groupIndex, attributeIds) {
addAttributes: function (groupIndex, attributeIds) {
attributeIds.forEach(function(attributeId) {
var attribute = this.custom_attributes.filter(attribute => attribute.id == attributeId)
var attribute = this.custom_attributes.filter(function (attribute) {
return attribute.id == attributeId;
});
attribute[0].removable = true;
@ -309,7 +313,7 @@
})
},
removeAttribute (groupIndex, attribute) {
removeAttribute: function (groupIndex, attribute) {
let index = this.groups[groupIndex].custom_attributes.indexOf(attribute)
this.groups[groupIndex].custom_attributes.splice(index, 1)
@ -319,7 +323,7 @@
this.custom_attributes = this.sortAttributes();
},
sortAttributes () {
sortAttributes: function () {
return this.custom_attributes.sort(function(a, b) {
return a.id - b.id;
});
@ -333,7 +337,7 @@
template: "#group-item-template",
computed: {
groupInputName () {
groupInputName: function () {
if (this.group.id)
return "attribute_groups[" + this.group.id + "]";
@ -342,11 +346,11 @@
},
methods: {
removeGroup () {
removeGroup: function () {
this.$emit('onRemoveGroup', this.group)
},
addAttributes (e) {
addAttributes: function (e) {
var attributeIds = [];
$(e.target).prev().find('li input').each(function() {
@ -364,7 +368,7 @@
this.$emit('onAttributeAdd', attributeIds)
},
removeAttribute (attribute) {
removeAttribute: function (attribute) {
var confirmDelete = confirm('Are you sure to do this?')
if (confirmDelete) {

View File

@ -3,7 +3,18 @@
{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.images.controls.before', ['product' => $product]) !!}
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="images" :images='@json($product->images)'></image-wrapper>
<div class="control-group {!! $errors->has('images.*') ? 'has-error' : '' !!}">
<label>{{ __('admin::app.catalog.categories.image') }}
<image-wrapper :button-label="'{{ __('admin::app.catalog.products.add-image-btn-title') }}'" input-name="images" :images='@json($product->images)'></image-wrapper>
<span class="control-error" v-if="{!! $errors->has('images.*') !!}">
@php $count=1 @endphp
@foreach ($errors->get('images.*') as $key => $message)
@php echo str_replace($key, 'Image'.$count, $message[0]); $count++ @endphp
@endforeach
</span>
</div>
{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.images.controls.after', ['product' => $product]) !!}

View File

@ -63,43 +63,45 @@
template: '#linked-products-template',
data: () => ({
products: {
'cross_sells': [],
'up_sells': [],
'related_products': []
},
data: function() {
return {
products: {
'cross_sells': [],
'up_sells': [],
'related_products': []
},
search_term: {
'cross_sells': '',
'up_sells': '',
'related_products': ''
},
search_term: {
'cross_sells': '',
'up_sells': '',
'related_products': ''
},
addedProducts: {
'cross_sells': [],
'up_sells': [],
'related_products': []
},
addedProducts: {
'cross_sells': [],
'up_sells': [],
'related_products': []
},
is_searching: {
'cross_sells': false,
'up_sells': false,
'related_products': false
},
is_searching: {
'cross_sells': false,
'up_sells': false,
'related_products': false
},
productId: {{ $product->id }},
productId: {{ $product->id }},
linkedProducts: ['up_sells', 'cross_sells', 'related_products'],
linkedProducts: ['up_sells', 'cross_sells', 'related_products'],
upSellingProducts: @json($product->up_sells()->get()),
upSellingProducts: @json($product->up_sells()->get()),
crossSellingProducts: @json($product->cross_sells()->get()),
crossSellingProducts: @json($product->cross_sells()->get()),
relatedProducts: @json($product->related_products()->get()),
}),
relatedProducts: @json($product->related_products()->get()),
}
},
created () {
created: function () {
if (this.upSellingProducts.length >= 1) {
for (var index in this.upSellingProducts) {
this.addedProducts.up_sells.push(this.upSellingProducts[index]);
@ -120,13 +122,13 @@
},
methods: {
addProduct (product, key) {
addProduct: function (product, key) {
this.addedProducts[key].push(product);
this.search_term[key] = '';
this.products[key] = []
},
removeProduct (product, key) {
removeProduct: function (product, key) {
for (var index in this.addedProducts[key]) {
if (this.addedProducts[key][index].id == product.id ) {
this.addedProducts[key].splice(index, 1);
@ -134,7 +136,7 @@
}
},
search (key) {
search: function (key) {
this_this = this;
this.is_searching[key] = true;

View File

@ -188,19 +188,21 @@
Vue.component('variant-form', {
data: () => ({
variant: {},
super_attributes: super_attributes
}),
data: function() {
return {
variant: {},
super_attributes: super_attributes
}
},
template: '#variant-form-template',
created () {
created: function () {
this.resetModel();
},
methods: {
addVariant (formScope) {
addVariant: function (formScope) {
this.$validator.validateAll(formScope).then((result) => {
if (result) {
var this_this = this;
@ -245,7 +247,7 @@
});
},
resetModel () {
resetModel: function () {
var this_this = this;
this.super_attributes.forEach(function(attribute) {
@ -261,13 +263,15 @@
inject: ['$validator'],
data: () => ({
variants: variants,
superAttributes: super_attributes
}),
data: function() {
return {
variants: variants,
superAttributes: super_attributes
}
},
methods: {
removeVariant(variant) {
removeVariant: function(variant) {
let index = this.variants.indexOf(variant)
this.variants.splice(index, 1)
@ -284,14 +288,16 @@
inject: ['$validator'],
data: () => ({
inventorySources: @json($inventorySources),
inventories: {},
totalQty: 0,
superAttributes: super_attributes
}),
data: function() {
return {
inventorySources: @json($inventorySources),
inventories: {},
totalQty: 0,
superAttributes: super_attributes
}
},
created () {
created: function () {
var this_this = this;
this.inventorySources.forEach(function(inventorySource) {
this_this.inventories[inventorySource.id] = this_this.sourceInventoryQty(inventorySource.id)
@ -300,7 +306,7 @@
},
computed: {
variantInputName () {
variantInputName: function () {
if (this.variant.id)
return "variants[" + this.variant.id + "]";
@ -309,11 +315,11 @@
},
methods: {
removeVariant () {
removeVariant: function () {
this.$emit('onRemoveVariant', this.variant)
},
optionName (optionId) {
optionName: function (optionId) {
var optionName = '';
this.superAttributes.forEach(function(attribute) {
@ -327,7 +333,7 @@
return optionName;
},
sourceInventoryQty (inventorySourceId) {
sourceInventoryQty: function (inventorySourceId) {
var inventories = this.variant.inventories.filter(function(inventory) {
return inventorySourceId === inventory.inventory_source_id;
})
@ -338,7 +344,7 @@
return 0;
},
updateTotalQty () {
updateTotalQty: function () {
this.totalQty = 0;
for (var key in this.inventories) {
this.totalQty += parseInt(this.inventories[key]);

View File

@ -255,19 +255,19 @@
props: ['code'],
data() {
data: function () {
return {
country: "",
}
},
mounted() {
mounted: function () {
this.country = this.code;
this.someHandler()
},
methods: {
someHandler() {
someHandler: function () {
this.$root.$emit('sendCountryCode', this.country)
},
}
@ -302,7 +302,7 @@
props: ['code'],
data() {
data: function () {
return {
state: "",
@ -312,15 +312,17 @@
}
},
mounted() {
mounted: function () {
this.state = this.code
},
methods: {
haveStates() {
this.$root.$on('sendCountryCode', (country) => {
this.country = country;
})
haveStates: function () {
var this_this = this;
this_this.$root.$on('sendCountryCode', function (country) {
this_this.country = country;
});
if (this.countryStates[this.country] && this.countryStates[this.country].length)
return true;

View File

@ -55,7 +55,7 @@
inject: ['$validator'],
data() {
data: function () {
return {
country: "{{ $countryCode }}",
@ -66,7 +66,7 @@
},
methods: {
haveStates() {
haveStates: function () {
if (this.countryStates[this.country] && this.countryStates[this.country].length)
return true;

View File

@ -379,13 +379,15 @@
template: '#date-filter-template',
data: () => ({
start: "{{ $startDate->format('Y-m-d') }}",
end: "{{ $endDate->format('Y-m-d') }}",
}),
data: function() {
return {
start: "{{ $startDate->format('Y-m-d') }}",
end: "{{ $endDate->format('Y-m-d') }}",
}
},
methods: {
applyFilter(field, date) {
applyFilter: function(field, date) {
this[field] = date;
window.location.href = "?start=" + this.start + '&end=' + this.end;

View File

@ -88,7 +88,7 @@
<div class="footer">
<p>
{{ trans('admin::app.footer.copy-right') }}
{{ core()->getConfigData('general.content.footer.footer_content') }}
</p>
</div>

View File

@ -1,12 +1,12 @@
@extends('admin::layouts.content')
@section('page_title')
{{ __('admin::app.promotion.add-catalog-rule') }}
{{ __('admin::app.promotion.add-cart-rule') }}
@stop
@section('content')
<div class="content">
<form method="POST" action="{{ route('admin.catalog-rule.store') }}" @submit.prevent="onSubmit">
<form method="POST" action="{{ route('admin.cart-rule.store') }}" @submit.prevent="onSubmit">
@csrf
<div class="page-header">
@ -14,7 +14,7 @@
<h1>
<i class="icon angle-left-icon back-link" onclick="history.length > 1 ? history.go(-1) : window.location = '{{ url('/admin/dashboard') }}';"></i>
{{ __('admin::app.promotion.add-catalog-rule') }}
{{ __('admin::app.promotion.add-cart-rule') }}
</h1>
</div>
@ -27,14 +27,14 @@
<div class="page-content">
<div class="form-container">
<catalog-rule></catalog-rule>
<cart-rule></cart-rule>
</div>
</div>
</form>
</div>
@push('scripts')
<script type="text/x-template" id="catalog-rule-form-template">
<script type="text/x-template" id="cart-rule-form-template">
<div>
@csrf()
@ -181,19 +181,6 @@
<span class="control-error" v-if="errors.has('apply')">@{{ errors.first('apply') }}</span>
</div>
<div class="control-group" :class="[errors.has('apply') ? 'has-error' : '']">
<label for="apply" class="required">Apply</label>
<select class="control" name="apply" v-model="apply" v-validate="'required'" value="{{ old('apply') }}" data-vv-as="&quot;Apply As&quot;">
<option value="1">Apply as percentage</option>
<option value="2">Apply as fixed Amount</option>
<option value="3">Adjust to percentage's value</option>
<option value="4">Adjust to discount value</option>
</select>
<span class="control-error" v-if="errors.has('apply')">@{{ errors.first('apply') }}</span>
</div>
<div class="control-group" :class="[errors.has('disc_amt') ? 'has-error' : '']">
<label for="disc_amt" class="required">{{ __('admin::app.promotion.general-info.disc_amt') }}</label>
<input type="text" class="control" name="disc_amt" v-model="disc_amt" v-validate="'required|numeric|max:1'" value="{{ old('disc_amt') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.disc_amt') }}&quot;">
@ -211,8 +198,8 @@
</script>
<script>
Vue.component('catalog-rule', {
template: '#catalog-rule-form-template',
Vue.component('cart-rule', {
template: '#cart-rule-form-template',
inject: ['$validator'],

View File

@ -78,17 +78,37 @@
<span class="control-error" v-if="errors.has('channels')">@{{ errors.first('channels') }}</span>
</div>
<div class="control-group" :class="[errors.has('starts_from') ? 'has-error' : '']">
<datetime :name="starts_from">
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
<input type="text" class="control" name="starts_from" v-model="starts_from" v-validate="'required'" value="{{ old('starts_from') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.starts-from') }}&quot;">
<div class="control-group">
<input type="text" class="control" name="starts_from" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.starts-from') }}&quot;">
</div>
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
</datetime>
<datetime :name="starts_from">
<div class="control-group">
<label for="ends_till" class="required">{{ __('admin::app.promotion.general-info.ends-till') }}</label>
<input type="text" class="control" name="ends_till" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.ends_till') }}&quot;">
<span class="control-error" v-if="errors.has('ends_till')">@{{ errors.first('ends_till') }}</span>
</div>
</datetime>
{{-- <div class="control-group" :class="[errors.has('starts_from') ? 'has-error' : '']">
<label for="starts_from" class="required">{{ __('admin::app.promotion.general-info.starts-from') }}</label>
<input type="datetime" class="control" name="starts_from" v-model="starts_from" v-validate="'required'" value="{{ old('starts_from') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.starts-from') }}&quot;">
<span class="control-error" v-if="errors.has('starts_from')">@{{ errors.first('starts_from') }}</span>
</div>
<div class="control-group" :class="[errors.has('ends_till') ? 'has-error' : '']">
<label for="ends_till" class="required">{{ __('admin::app.promotion.general-info.ends-till') }}</label>
<input type="text" class="control" name="ends_till" v-model="ends_till" v-validate="'required'" value="{{ old('ends_till') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.ends_till') }}&quot;">
<input type="datetime" class="control" name="ends_till" v-model="ends_till" v-validate="'required'" value="{{ old('ends_till') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.ends_till') }}&quot;">
<span class="control-error" v-if="errors.has('ends_till')">@{{ errors.first('ends_till') }}</span>
</div>
</div> --}}
<div class="control-group" :class="[errors.has('priority') ? 'has-error' : '']">
<label for="priority" class="required">{{ __('admin::app.promotion.general-info.priority') }}</label>
@ -171,38 +191,25 @@
<div class="control-group" :class="[errors.has('apply') ? 'has-error' : '']">
<label for="apply" class="required">Apply</label>
<select class="control" name="apply" v-model="apply" v-validate="'required'" value="{{ old('apply') }}" data-vv-as="&quot;Apply As&quot;">
<option value="1">Apply as percentage</option>
<option value="2">Apply as fixed Amount</option>
<option value="3">Adjust to percentage's value</option>
<option value="4">Adjust to discount value</option>
<select class="control" name="apply" v-model="apply" v-validate="'required'" value="{{ old('apply') }}" data-vv-as="&quot;Apply As&quot;" v-on:change="detectApply">
<option value="1">{{ __('admin::app.promotion.catalog.apply-percent') }}</option>
<option value="2">{{ __('admin::app.promotion.catalog.apply-fixed') }}</option>
<option value="3">{{ __('admin::app.promotion.catalog.adjust-to-percent') }}</option>
<option value="4">{{ __('admin::app.promotion.catalog.adjust-to-value') }}</option>
</select>
<span class="control-error" v-if="errors.has('apply')">@{{ errors.first('apply') }}</span>
</div>
<div class="control-group" :class="[errors.has('apply') ? 'has-error' : '']">
<label for="apply" class="required">Apply</label>
<select class="control" name="apply" v-model="apply" v-validate="'required'" value="{{ old('apply') }}" data-vv-as="&quot;Apply As&quot;">
<option value="1">Apply as percentage</option>
<option value="2">Apply as fixed Amount</option>
<option value="3">Adjust to percentage's value</option>
<option value="4">Adjust to discount value</option>
</select>
<span class="control-error" v-if="errors.has('apply')">@{{ errors.first('apply') }}</span>
</div>
<div class="control-group" :class="[errors.has('disc_amt') ? 'has-error' : '']">
<div class="control-group" :class="[errors.has('disc_amt') ? 'has-error' : '']" v-if="apply_amt">
<label for="disc_amt" class="required">{{ __('admin::app.promotion.general-info.disc_amt') }}</label>
<input type="text" class="control" name="disc_amt" v-model="disc_amt" v-validate="'required|numeric|max:1'" value="{{ old('disc_amt') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.disc_amt') }}&quot;">
<input type="text" class="control" name="disc_amt" v-model="disc_amt" v-validate="'required|numeric'" value="{{ old('disc_amt') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.disc_amt') }}&quot;">
<span class="control-error" v-if="errors.has('disc_amt')">@{{ errors.first('disc_amt') }}</span>
</div>
<div class="control-group" :class="[errors.has('disc_percent') ? 'has-error' : '']">
<div class="control-group" :class="[errors.has('disc_percent') ? 'has-error' : '']" v-if="apply_prct">
<label for="disc_percent" class="required">{{ __('admin::app.promotion.general-info.disc_percent') }}</label>
<input type="text" class="control" name="disc_percent" v-model="disc_percent" v-validate="'required|numeric|max:1'" value="{{ old('disc_percent') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.disc_percent') }}&quot;">
<input type="text" class="control" name="disc_percent" v-model="disc_percent" v-validate="'required|numeric|max:2'" value="{{ old('disc_percent') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.disc_percent') }}&quot;">
<span class="control-error" v-if="errors.has('disc_percent')">@{{ errors.first('disc_percent') }}</span>
</div>
</div>
@ -226,11 +233,15 @@
cats_count: 0,
name: '10% OFF',
priority: 1,
starts_from: 'a',
ends_till: 'b',
starts_from: null,
ends_till: null,
description: 'something',
customer_groups: [],
criteria: null,
apply: null,
apply_amt: false,
apply_prct: false,
end_other_rules: null,
attr: {
attribute: null,
condition: null,
@ -276,6 +287,16 @@
}
},
detectApply() {
if (this.apply == 1 || this.apply == 3) {
this.apply_prct = true;
this.apply_amt = false;
} else if (this.apply == 2 || this.apply == 4) {
this.apply_prct = false;
this.apply_amt = true;
}
},
removeAttr(index) {
this.attrs.splice(index, 1);
},

View File

@ -362,7 +362,7 @@
inject: ['$validator'],
data() {
data: function() {
return {
source: ""
}

View File

@ -90,7 +90,7 @@
inject: ['$validator'],
data() {
data: function () {
return {
is_zip: false
}

View File

@ -8,6 +8,7 @@ use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Mail;
use Webkul\Customer\Mail\VerificationEmail;
use Illuminate\Routing\Controller;
use Webkul\Customer\Repositories\CustomerRepository as Customer;
use Webkul\Customer\Repositories\CustomerGroupRepository as CustomerGroup;
use Cookie;
@ -25,14 +26,16 @@ class RegistrationController extends Controller
* @return \Illuminate\Http\Response
*/
protected $_config;
protected $customer;
protected $customerGroup;
/**
* @param CustomerRepository object $customer
*/
public function __construct(CustomerGroup $customerGroup)
public function __construct(CustomerGroup $customerGroup, Customer $customer)
{
$this->_config = request('_config');
$this->customer = $customer;
$this->customerGroup = $customerGroup;
}
@ -72,9 +75,13 @@ class RegistrationController extends Controller
$data['is_verified'] = 1;
}
$customerGroup = $this->customerGroup->findOneWhere(['name' => 'General', 'is_user_defined' => 0]);
$customerGroup = $this->customerGroup->findOneWhere([
'name' => 'General',
'is_user_defined' => 0
]);
$data['customer_group_id'] = $this->customerGroup->id;
if (isset($customerGroup))
$data['customer_group_id'] = $customerGroup->id;
$verificationData['email'] = $data['email'];
$verificationData['token'] = md5(uniqid(rand(), true));

View File

@ -0,0 +1,7 @@
<?php
namespace Webkul\Discount\Contracts;
interface CatalogRule
{
}

View File

@ -0,0 +1,7 @@
<?php
namespace Webkul\Discount\Contracts;
interface CatalogRuleChannels
{
}

View File

@ -0,0 +1,7 @@
<?php
namespace Webkul\Discount\Contracts;
interface CatalogRuleCustomerGroups
{
}

View File

@ -1,31 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class DropAllDiscountsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('discount_customer_group');
Schema::dropIfExists('discount_channels');
Schema::dropIfExists('discount_rules');
Schema::dropIfExists('discounts');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@ -13,8 +13,23 @@ class CreateCatalogRulesTable extends Migration
*/
public function up()
{
Schema::dropIfExists('discount_customer_group');
Schema::dropIfExists('discount_channels');
Schema::dropIfExists('discount_rules');
Schema::dropIfExists('discounts');
Schema::create('catalog_rules', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('description')->nullable();
$table->datetime('starts_from');
$table->datetime('ends_till');
$table->json('conditions');
$table->json('actions');
$table->boolean('ends_other_rules');
$table->integer('sort_order')->unsigned();
$table->string('action_type');
$table->string('discount_amount');
$table->timestamps();
});
}

View File

@ -1,31 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCheckoutRulesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('checkout_rules', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('checkout_rules');
}
}

View File

@ -15,6 +15,11 @@ class CreateCatalogProductsTable extends Migration
{
Schema::create('catalog_products', function (Blueprint $table) {
$table->increments('id');
$table->integer('catalog_rule_id')->unsigned();
$table->foreign('catalog_rule_id')->references('id')->on('catalog_rules')->onDelete('cascade');
$table->integer('product_id')->unsigned();
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
$table->decimal('price', 12, 4);
$table->timestamps();
});
}
@ -28,4 +33,4 @@ class CreateCatalogProductsTable extends Migration
{
Schema::dropIfExists('catalog_products');
}
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCatalogRuleCustomerGroupsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('catalog_rule_customer_groups', function (Blueprint $table) {
$table->increments('id');
$table->integer('catalog_rule_id')->unsigned();
$table->foreign('catalog_rule_id')->references('id')->on('catalog_rules')->onDelete('cascade');
$table->integer('customer_group_id')->unsigned();
$table->foreign('customer_group_id')->references('id')->on('customer_groups')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('catalog_rule_customer_groups');
}
}

View File

@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCatalogRuleChannelsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('catalog_rule_channels', function (Blueprint $table) {
$table->increments('id');
$table->integer('catalog_rule_id')->unsigned();
$table->foreign('catalog_rule_id')->references('id')->on('catalog_rules')->onDelete('cascade');
$table->integer('channel_id')->unsigned();
$table->foreign('channel_id')->references('id')->on('channels')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('catalog_rule_channels');
}
}

View File

@ -6,6 +6,11 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;
use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
use Webkul\Category\Repositories\CategoryRepository as Category;
use Webkul\Product\Repositories\ProductFlatRepository as Product;
/**
* Cart Rule controller
*
@ -15,15 +20,23 @@ use Illuminate\Routing\Controller;
class CartRuleController extends Controller
{
protected $_config;
protected $attribute;
protected $attributeFamily;
protected $category;
protected $product;
public function __construct()
public function __construct(Attribute $attribute, AttributeFamily $attributeFamily, Category $category, Product $product)
{
$this->_config = request('_config');
$this->attribute = $attribute;
$this->attributeFamily = $attributeFamily;
$this->category = $category;
$this->product = $product;
}
public function index()
{
return view($this->_config['view']);
return view($this->_config['view'])->with('criteria', [$this->attribute->getNameAndId(), $this->category->getNameAndId()]);
}
public function create()

View File

@ -10,6 +10,7 @@ use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
use Webkul\Category\Repositories\CategoryRepository as Category;
use Webkul\Product\Repositories\ProductFlatRepository as Product;
use Webkul\Discount\Repositories\CatalogRuleRepository as CatalogRule;
/**
* Catalog Rule controller
@ -19,19 +20,61 @@ use Webkul\Product\Repositories\ProductFlatRepository as Product;
*/
class CatalogRuleController extends Controller
{
/**
* Initialize _config, a default request parameter with route
*/
protected $_config;
/**
* Attribute $attribute
*/
protected $attribute;
/**
* AttributeFamily $attributeFamily
*/
protected $attributeFamily;
/**
* Category $category
*/
protected $category;
/**
* Product $product
*/
protected $product;
public function __construct(Attribute $attribute, AttributeFamily $attributeFamily, Category $category, Product $product)
/**
* Property for catalog rule application
*/
protected $appliedConfig;
/**
* To hold the catalog repository instance
*/
protected $catalogRule;
public function __construct(Attribute $attribute, AttributeFamily $attributeFamily, Category $category, Product $product, CatalogRule $catalogRule)
{
$this->_config = request('_config');
$this->attribute = $attribute;
$this->attributeFamily = $attributeFamily;
$this->category = $category;
$this->product = $product;
$this->catalogRule = $catalogRule;
$this->appliedConfig = [
0 => trans('admin::app.promotion.catalog.apply-percent'),
1 => trans('admin::app.promotion.catalog.apply-fixed'),
2 => trans('admin::app.promotion.catalog.adjust-to-percent'),
3 => trans('admin::app.promotion.catalog.adjust-to-value')
];
}
public function index()
@ -46,7 +89,17 @@ class CatalogRuleController extends Controller
public function store()
{
dd(request()->all());
$this->validate(request(), [
'name' => 'required|string',
'description' => 'string',
'customer_groups' => 'required|array',
'channels' => 'required|array',
'starts_from' => 'required|date_format:Y-m-d H:i:s',
'ends_till' => 'required|date_format:Y-m-d H:i:s',
'apply' => 'numeric|min:1|max:4'
]);
$catalogRule = $this->catalogRule->create(request()->all());
}
public function fetchAttribute()

View File

@ -1,5 +0,0 @@
<?php
namespace Webkul\Discount\Models;
// use Illuminate\

View File

@ -0,0 +1,13 @@
<?php
namespace Webkul\Discount\Models;
use Illuminate\Database\Eloquent\Model;
use Webkul\Discount\Contracts\CatalogRule as CatalogRuleContract;
class CatalogRule extends Model implements CatalogRuleContract
{
protected $table = 'catalog_rules';
protected $guarded = ['created_at', 'updated_at'];
}

View File

@ -0,0 +1,13 @@
<?php
namespace Webkul\Discount\Models;
use Illuminate\Database\Eloquent\Model;
use Webkul\Discount\Contracts\CatalogRuleChannels as CatalogRuleChannelsContract;
class CatalogRuleChannels extends Model implements CatalogRuleChannelsContract
{
protected $table = 'catalog_rule_channels';
protected $guarded = ['created_at', 'updated_at'];
}

View File

@ -0,0 +1,10 @@
<?php
namespace Webkul\Discount\Models;
use Konekt\Concord\Proxies\ModelProxy;
class CatalogRuleChannelsProxy extends ModelProxy
{
}

View File

@ -0,0 +1,13 @@
<?php
namespace Webkul\Discount\Models;
use Illuminate\Database\Eloquent\Model;
use Webkul\Discount\Contracts\CatalogRuleCustomerGroups as CatalogRuleCustomerGroupsContract;
class CatalogRuleCustomerGroups extends Model implements CatalogRuleCustomerGroupsContract
{
protected $table = 'catalog_rule_customer_groups';
protected $guarded = ['created_at', 'updated_at'];
}

View File

@ -0,0 +1,10 @@
<?php
namespace Webkul\Discount\Models;
use Konekt\Concord\Proxies\ModelProxy;
class CatalogRuleCustomerGroupsProxy extends ModelProxy
{
}

View File

@ -0,0 +1,10 @@
<?php
namespace Webkul\Discount\Models;
use Konekt\Concord\Proxies\ModelProxy;
class CatalogRuleProxy extends ModelProxy
{
}

View File

@ -0,0 +1,24 @@
<?php
namespace Webkul\Discount\Repositories;
use Webkul\Core\Eloquent\Repository;
/**
* Catalog Rule Reposotory
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CatalogRuleRepository extends Repository
{
/**
* Specify Model class name
*
* @return mixed
*/
function model()
{
return 'Webkul\Discount\Contracts\CatalogRule';
}
}

View File

@ -74,6 +74,7 @@ class ProductForm extends FormRequest
'variants.*.sku' => 'required',
'variants.*.price' => 'required',
'variants.*.weight' => 'required',
'images.*' => 'mimes:jpeg,jpg,bmp,png',
];
$inputs = $this->all();

View File

@ -468,6 +468,10 @@ class ProductRepository extends Repository
->where('flat_variants.locale', $locale);
});
if (isset($params['search'])) {
$qb->where('product_flat.name', 'like', '%' . urldecode($params['search']) . '%');
}
if (isset($params['sort'])) {
$attribute = $this->attribute->findOneByField('code', $params['sort']);

View File

@ -18,9 +18,9 @@
"vue": "^2.1.10"
},
"dependencies": {
"ez-plus": "^1.2.1",
"vee-validate": "2.0.0-rc.26",
"vue-flatpickr": "^2.3.0",
"vue-slider-component": "^2.7.5",
"ez-plus": "^1.2.1"
"vue-slider-component": "^2.7.5"
}
}

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="8px" height="8px" viewBox="0 0 8 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 51.1 (57501) - http://www.bohemiancoding.com/sketch -->
<title>icon-dropdown</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="icon-dropdown" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<polygon id="" fill="#242424" transform="translate(4.000000, 4.514496) rotate(-270.000000) translate(-4.000000, -4.514496) " points="1.48080444 8.51449585 4.54690552 4.51449585 1.48080444 0.51449585 3.48550415 0.51449585 6.51919556 4.51449585 3.48550415 8.51449585"></polygon>
</g>
</svg>

After

Width:  |  Height:  |  Size: 745 B

View File

@ -1340,7 +1340,7 @@ section.slider-block {
}
.icon {
background-image: url('../images/arrow-down.svg') !important;
background-image: url('../images/icon-dropdown.svg') !important;
width: 10px;
height: 10px;
position: absolute;
@ -2135,6 +2135,14 @@ section.cart {
margin-top: 18px;
margin-right: 15px;
}
.quantity-change {
cursor: pointer;
&:focus {
border-color: $border-color !important;
}
}
}
}

View File

@ -153,3 +153,7 @@
background-image: url("../images/linkedin.svg");
}
.icon-dropdown {
background-image: url("../images/icon-dropdown.svg");
}

View File

@ -18,7 +18,7 @@
<div class="cart-item-list" style="margin-top: 0">
@csrf
@foreach ($cart->items as $item)
@foreach ($cart->items as $key => $item)
<?php
if ($item->type == "configurable")
$productBaseImage = $productImageHelper->getProductBaseImage($item->child->product);
@ -74,7 +74,12 @@
<div class="wrap">
<label for="qty[{{$item->id}}]">{{ __('shop::app.checkout.cart.quantity.quantity') }}</label>
<input type="text" class="control" v-validate="'required|numeric|min_value:1'" name="qty[{{$item->id}}]" value="{{ $item->quantity }}" data-vv-as="&quot;{{ __('shop::app.checkout.cart.quantity.quantity') }}&quot;">
<input class="control quantity-change" value="-" style="width: 35px; border-radius: 3px 0px 0px 3px;" onclick="updateCartQunatity('remove', {{$key}})" readonly>
<input type="text" class="control quantity-change" id="cart-quantity{{ $key
}}" v-validate="'required|numeric|min_value:1'" name="qty[{{$item->id}}]" value="{{ $item->quantity }}" data-vv-as="&quot;{{ __('shop::app.checkout.cart.quantity.quantity') }}&quot;" style="border-right: none; border-left: none; border-radius: 0px;" readonly>
<input class="control quantity-change" value="+" style="width: 35px; padding: 0 12px; border-radius: 0px 3px 3px 0px;" onclick="updateCartQunatity('add', {{$key}})" readonly>
</div>
<span class="control-error" v-if="errors.has('qty[{{$item->id}}]')">@{{ errors.first('qty[{!!$item->id!!}]') }}</span>
@ -167,5 +172,21 @@
if (!confirm(message))
event.preventDefault();
}
function updateCartQunatity(operation, index) {
var quantity = document.getElementById('cart-quantity'+index).value;
if (operation == 'add') {
quantity = parseInt(quantity) + 1;
} else if (operation == 'remove') {
if (quantity > 1) {
quantity = parseInt(quantity) - 1;
} else {
alert('{{ __('shop::app.products.less-quantity') }}');
}
}
document.getElementById('cart-quantity'+index).value = quantity;
event.preventDefault();
}
</script>
@endpush

View File

@ -116,7 +116,27 @@
var shippingHtml = '';
var paymentHtml = '';
var reviewHtml = '';
var summaryHtml = Vue.compile(`<?php echo view('shop::checkout.total.summary', ['cart' => $cart])->render(); ?>`);
var summaryHtml = Vue.compile(
"<div class='order-summary'><h3>"
+ '{{ __('shop::app.checkout.total.order-summary') }}' +
"</h3><div class='item-detail'><label>"
+ '{{ intval($cart->items_qty) }} {{ __('shop::app.checkout.total.sub-total') }} {{ __('shop::app.checkout.total.price') }}' +
"</label><label class='right'>"
+ '{{ core()->currency($cart->base_sub_total) }}' +
"</label></div><?php if($cart->base_tax_total): ?><div class='item-detail'><label>"
+ '{{ __('shop::app.checkout.total.tax') }}' +
"</label><label class='right'>"
+ '{{ core()->currency($cart->base_tax_total) }}' +
"</label></div><?php endif; ?><?php if($cart->selected_shipping_rate): ?><div class='item-detail'><label>"
+ '{{ __('shop::app.checkout.total.delivery-charges') }}' +
"</label><label class='right'>"
+ '{{ core()->currency($cart->selected_shipping_rate->base_price) }}' +
"</label></div><?php endif; ?><div class='payble-amount'><label>"
+ '{{ __('shop::app.checkout.total.grand-total') }}' +
"</label><label class='right'>"
+ '{{ core()->currency($cart->base_grand_total) }}' +
"</label></div></div>"
);
var customerAddress = null;
@auth('customer')
@ -132,7 +152,7 @@
template: '#checkout-template',
inject: ['$validator'],
data() {
data: function() {
return {
currentStep: 1,
completedStep: 0,
@ -159,7 +179,7 @@
}
},
created() {
created: function() {
if(! customerAddress) {
this.new_shipping_address = true;
this.new_billing_address = true;
@ -184,35 +204,37 @@
},
methods: {
navigateToStep (step) {
navigateToStep: function(step) {
if (step <= this.completedStep) {
this.currentStep = step
this.completedStep = step - 1;
}
},
haveStates(addressType) {
haveStates: function(addressType) {
if (this.countryStates[this.address[addressType].country] && this.countryStates[this.address[addressType].country].length)
return true;
return false;
},
validateForm: function (scope) {
this.$validator.validateAll(scope).then((result) => {
validateForm: function(scope) {
var this_this = this;
this.$validator.validateAll(scope).then(function (result) {
if (result) {
if (scope == 'address-form') {
this.saveAddress()
this_this.saveAddress();
} else if (scope == 'shipping-form') {
this.saveShipping()
this_this.saveShipping();
} else if (scope == 'payment-form') {
this.savePayment()
this_this.savePayment();
}
}
});
},
saveAddress () {
saveAddress: function() {
var this_this = this;
this.disable_button = true;
@ -234,7 +256,7 @@
})
},
saveShipping () {
saveShipping: function() {
var this_this = this;
this.disable_button = true;
@ -256,7 +278,7 @@
})
},
savePayment () {
savePayment: function() {
var this_this = this;
this.disable_button = true;
@ -278,7 +300,7 @@
})
},
placeOrder () {
placeOrder: function() {
var this_this = this;
this.disable_button = true;
@ -302,7 +324,7 @@
})
},
handleErrorResponse (response, scope) {
handleErrorResponse: function(response, scope) {
if (response.status == 422) {
serverErrors = response.data.errors;
this.$root.addServerErrors(scope)
@ -313,19 +335,19 @@
}
},
shippingMethodSelected (shippingMethod) {
shippingMethodSelected: function(shippingMethod) {
this.selected_shipping_method = shippingMethod;
},
paymentMethodSelected (paymentMethod) {
paymentMethodSelected: function(paymentMethod) {
this.selected_payment_method = paymentMethod;
},
newBillingAddress() {
newBillingAddress: function() {
this.new_billing_address = true;
},
newShippingAddress() {
newShippingAddress: function() {
this.new_shipping_address = true;
}
}
@ -335,7 +357,7 @@
Vue.component('summary-section', {
inject: ['$validator'],
data() {
data: function() {
return {
templateRender: null
}
@ -343,7 +365,7 @@
staticRenderFns: summaryTemplateRenderFns,
mounted() {
mounted: function() {
this.templateRender = summaryHtml.render;
for (var i in summaryHtml.staticRenderFns) {
@ -351,7 +373,7 @@
}
},
render(h) {
render: function(h) {
return h('div', [
(this.templateRender ?
this.templateRender() :
@ -364,7 +386,7 @@
Vue.component('shipping-section', {
inject: ['$validator'],
data() {
data: function() {
return {
templateRender: null,
selected_shipping_method: '',
@ -373,7 +395,7 @@
staticRenderFns: shippingTemplateRenderFns,
mounted() {
mounted: function() {
this.templateRender = shippingHtml.render;
for (var i in shippingHtml.staticRenderFns) {
shippingTemplateRenderFns.push(shippingHtml.staticRenderFns[i]);
@ -382,7 +404,7 @@
eventBus.$emit('after-checkout-shipping-section-added');
},
render(h) {
render: function(h) {
return h('div', [
(this.templateRender ?
this.templateRender() :
@ -391,7 +413,7 @@
},
methods: {
methodSelected () {
methodSelected: function() {
this.$emit('onShippingMethodSelected', this.selected_shipping_method)
eventBus.$emit('after-shipping-method-selected');
@ -403,7 +425,7 @@
Vue.component('payment-section', {
inject: ['$validator'],
data() {
data: function() {
return {
templateRender: null,
@ -415,7 +437,7 @@
staticRenderFns: paymentTemplateRenderFns,
mounted() {
mounted: function() {
this.templateRender = paymentHtml.render;
for (var i in paymentHtml.staticRenderFns) {
@ -425,7 +447,7 @@
eventBus.$emit('after-checkout-payment-section-added');
},
render(h) {
render: function(h) {
return h('div', [
(this.templateRender ?
this.templateRender() :
@ -434,7 +456,7 @@
},
methods: {
methodSelected () {
methodSelected: function() {
this.$emit('onPaymentMethodSelected', this.payment)
eventBus.$emit('after-payment-method-selected');
@ -444,7 +466,7 @@
var reviewTemplateRenderFns = [];
Vue.component('review-section', {
data() {
data: function() {
return {
templateRender: null
}
@ -452,7 +474,7 @@
staticRenderFns: reviewTemplateRenderFns,
mounted() {
mounted: function() {
this.templateRender = reviewHtml.render;
for (var i in reviewHtml.staticRenderFns) {
@ -460,7 +482,7 @@
}
},
render(h) {
render: function(h) {
return h('div', [
(this.templateRender ?
this.templateRender() :

View File

@ -42,20 +42,22 @@ foreach (app('Webkul\Category\Repositories\CategoryRepository')->getVisibleCateg
categories: {
type: [Array, String, Object],
required: false,
default: () => ([])
default: (function () {
return [];
})
},
url: String
},
data(){
data: function(){
return {
items_count:0
};
},
computed: {
items () {
items: function() {
return JSON.parse(this.categories)
}
},
@ -93,7 +95,7 @@ foreach (app('Webkul\Category\Repositories\CategoryRepository')->getVisibleCateg
url: String,
},
data() {
data: function() {
return {
items_count:0,
show: false,
@ -107,11 +109,11 @@ foreach (app('Webkul\Category\Repositories\CategoryRepository')->getVisibleCateg
},
computed: {
haveChildren() {
haveChildren: function() {
return this.item.children.length ? true : false;
},
name() {
name: function() {
if (this.item.translations && this.item.translations.length) {
this.item.translations.forEach(function(translation) {
if (translation.locale == document.documentElement.lang)

View File

@ -67,7 +67,7 @@
<div class="footer-bottom">
<p>
{{ __('shop::app.webkul.copy-right', ['year' => date('Y')]) }}
{{ core()->getConfigData('general.content.footer.footer_content') }}
</p>
</div>

View File

@ -81,25 +81,31 @@
template: '#layered-navigation-template',
data() {
data: function() {
return {
attributes: @json($attributeRepository->getFilterAttributes()),
appliedFilters: {}
}
},
created () {
created: function () {
var urlParams = new URLSearchParams(window.location.search);
var entries = urlParams.entries();
//var entries = urlParams.entries();
for(pair of entries) {
this.appliedFilters[pair[0]] = pair[1].split(',');
}
//for (let pair of entries) {
//this.appliedFilters[pair[0]] = pair[1].split(',');
//}
var this_this = this;
urlParams.forEach(function (value, index) {
this_this.appliedFilters[index] = value.split(',');
});
},
methods: {
addFilters (attributeCode, filters) {
addFilters: function (attributeCode, filters) {
if (filters.length) {
this.appliedFilters[attributeCode] = filters;
} else {
@ -109,7 +115,7 @@
this.applyFilter()
},
applyFilter () {
applyFilter: function () {
var params = [];
for(key in this.appliedFilters) {
@ -119,7 +125,6 @@
window.location.href = "?" + params.join('&');
}
}
});
Vue.component('filter-attribute-item', {
@ -128,28 +133,30 @@
props: ['index', 'attribute', 'appliedFilterValues'],
data: () => ({
appliedFilters: [],
data: function() {
return {
appliedFilters: [],
active: false,
active: false,
sliderConfig: {
value: [
0,
0
],
max: 500,
processStyle: {
"backgroundColor": "#FF6472"
},
tooltipStyle: {
"backgroundColor": "#FF6472",
"borderColor": "#FF6472"
sliderConfig: {
value: [
0,
0
],
max: 500,
processStyle: {
"backgroundColor": "#FF6472"
},
tooltipStyle: {
"backgroundColor": "#FF6472",
"borderColor": "#FF6472"
}
}
}
}),
},
created () {
created: function () {
if (!this.index)
this.active = true;
@ -165,17 +172,17 @@
},
methods: {
addFilter (e) {
addFilter: function (e) {
this.$emit('onFilterAdded', this.appliedFilters)
},
priceRangeUpdated (value) {
priceRangeUpdated: function (value) {
this.appliedFilters = value;
this.$emit('onFilterAdded', this.appliedFilters)
},
clearFilters () {
clearFilters: function () {
if (this.attribute.type == 'price') {
this.sliderConfig.value = [0, 0];
}

View File

@ -121,19 +121,19 @@
inject: ['$validator'],
methods: {
onSubmit (e) {
onSubmit: function(e) {
if (e.target.getAttribute('type') != 'submit')
return;
e.preventDefault();
this.$validator.validateAll().then(result => {
this.$validator.validateAll().then(function (result) {
if (result) {
if (e.target.getAttribute('data-href')) {
window.location.href = e.target.getAttribute('data-href');
} else {
document.getElementById('product-form').submit();
}
if (e.target.getAttribute('data-href')) {
window.location.href = e.target.getAttribute('data-href');
} else {
document.getElementById('product-form').submit();
}
}
});
}

View File

@ -20,7 +20,7 @@
@else
<td>{{ $attribute['admin_name'] }}</td>
@endif
<td>{{ $attribute['value'] }}</>
<td>{{ $attribute['value'] }}</td>
</tr>
@endforeach

View File

@ -79,7 +79,7 @@
inject: ['$validator'],
data() {
data: function() {
return {
config: @json($config),
@ -93,7 +93,7 @@
}
},
created () {
created: function() {
this.galleryImages = galleryImages.slice(0)
var config = @json($config);
@ -125,7 +125,7 @@
},
methods: {
configure (attribute, value) {
configure: function(attribute, value) {
this.simpleProduct = this.getSelectedProductId(attribute, value);
if (value) {
@ -170,7 +170,7 @@
this.changeStock(this.simpleProduct);
},
getSelectedIndex (attribute, value) {
getSelectedIndex: function(attribute, value) {
var selectedIndex = 0;
attribute.options.forEach(function(option, index) {
@ -182,7 +182,7 @@
return selectedIndex;
},
getSelectedProductId (attribute, value) {
getSelectedProductId: function(attribute, value) {
var options = attribute.options,
matchedOptions;
@ -197,7 +197,7 @@
return undefined;
},
fillSelect (attribute) {
fillSelect: function(attribute) {
var options = this.getAttributeOptions(attribute.id),
prevOption,
index = 1,
@ -238,7 +238,7 @@
}
},
resetChildren (attribute) {
resetChildren: function(attribute) {
if (attribute.childAttributes) {
attribute.childAttributes.forEach(function (set) {
set.selectedIndex = 0;
@ -268,7 +268,7 @@
}
},
getAttributeOptions (attributeId) {
getAttributeOptions: function (attributeId) {
var this_this = this,
options;
@ -281,7 +281,7 @@
return options;
},
reloadPrice () {
reloadPrice: function () {
var selectedOptionCount = 0;
this.childAttributes.forEach(function(attribute) {
@ -308,7 +308,7 @@
}
},
changeProductImages () {
changeProductImages: function () {
galleryImages.splice(0, galleryImages.length)
this.galleryImages.forEach(function(image) {
@ -322,7 +322,7 @@
}
},
changeStock(productId) {
changeStock: function (productId) {
var inStockElement = document.getElementById('in-stock');
if (productId) {

View File

@ -76,14 +76,14 @@
}
},
created () {
created: function() {
this.changeImage(this.images[0])
this.prepareThumbs()
},
methods: {
prepareThumbs () {
prepareThumbs: function() {
var this_this = this;
this_this.thumbs = [];
@ -92,29 +92,29 @@
});
},
changeImage (image) {
changeImage: function(image) {
this.currentLargeImageUrl = image.large_image_url;
this.currentOriginalImageUrl = image.original_image_url;
$('img#pro-img').data('zoom-image', image.original_image_url).ezPlus();
},
moveThumbs(direction) {
moveThumbs: function(direction) {
let len = this.thumbs.length;
if (direction === "top") {
const moveThumb = this.thumbs.splice(len - 1, 1);
this.thumbs = [moveThumb[0], ...this.thumbs];
this.counter.up = this.counter.up+1;
this.counter.down = this.counter.down-1;
this.thumbs = [moveThumb[0]].concat((this.thumbs));
this.counter.up = this.counter.up + 1;
this.counter.down = this.counter.down - 1;
} else {
const moveThumb = this.thumbs.splice(0, 1);
this.thumbs = [...this.thumbs, moveThumb[0]];
this.counter.down = this.counter.down+1;
this.counter.up = this.counter.up-1;
this.thumbs = [].concat((this.thumbs), [moveThumb[0]]);
this.counter.down = this.counter.down + 1;
this.counter.up = this.counter.up - 1;
}
if ((len-4) == this.counter.down) {
@ -141,7 +141,6 @@
$(document).mousemove(function(event) {
if ($('.add-to-wishlist').length) {
if (event.pageX > $('.add-to-wishlist').offset().left && event.pageX < $('.add-to-wishlist').offset().left+32 && event.pageY > $('.add-to-wishlist').offset().top && event.pageY < $('.add-to-wishlist').offset().top+32) {
$(".zoomContainer").addClass("show-wishlist");
} else {
@ -157,5 +156,4 @@
});
})
</script>
@endpush

View File

@ -19,7 +19,10 @@
"flatpickr": "^4.4.6"
},
"dependencies": {
"@babel/polyfill": "^7.4.4",
"tooltip.js": "^1.3.1",
"url-polyfill": "^1.1.5",
"url-search-params-polyfill": "^6.0.0",
"vue-swatches": "^1.0.3"
}
}

View File

@ -1,3 +1,4 @@
Vue.component("flash-wrapper", require("./components/flash-wrapper"));
Vue.component("flash", require("./components/flash"));
Vue.component("tabs", require("./components/tabs/tabs"));
@ -20,4 +21,10 @@ Vue.component("swatch-picker", require("./components/swatch-picker"));
require('flatpickr/dist/flatpickr.css');
require('vue-swatches/dist/vue-swatches.min.css');
require('vue-swatches/dist/vue-swatches.min.css');
require("@babel/polyfill");
require('url-search-params-polyfill');
require('url-polyfill');

View File

@ -224,53 +224,55 @@
Vue.component('datagrid-filters', {
template: '#datagrid-filters',
data: () => ({
filterIndex: @json($results['index']),
gridCurrentData: @json($results['records']),
massActions: @json($results['massactions']),
massActionsToggle: false,
massActionTarget: null,
massActionType: null,
massActionValues: [],
massActionTargets: [],
massActionUpdateValue: null,
url: new URL(window.location.href),
currentSort: null,
dataIds: [],
allSelected: false,
sortDesc: 'desc',
sortAsc: 'asc',
sortUpIcon: 'sort-up-icon',
sortDownIcon: 'sort-down-icon',
currentSortIcon: null,
isActive: false,
isHidden: true,
searchValue: '',
filterColumn: true,
filters: [],
columnOrAlias: '',
type: null,
columns : @json($results['columns']),
stringCondition: null,
booleanCondition: null,
numberCondition: null,
datetimeCondition: null,
stringValue: null,
booleanValue: null,
datetimeValue: '2000-01-01',
numberValue: 0,
stringConditionSelect: false,
booleanConditionSelect: false,
numberConditionSelect: false,
datetimeConditionSelect: false
}),
data: function() {
return {
filterIndex: @json($results['index']),
gridCurrentData: @json($results['records']),
massActions: @json($results['massactions']),
massActionsToggle: false,
massActionTarget: null,
massActionType: null,
massActionValues: [],
massActionTargets: [],
massActionUpdateValue: null,
url: new URL(window.location.href),
currentSort: null,
dataIds: [],
allSelected: false,
sortDesc: 'desc',
sortAsc: 'asc',
sortUpIcon: 'sort-up-icon',
sortDownIcon: 'sort-down-icon',
currentSortIcon: null,
isActive: false,
isHidden: true,
searchValue: '',
filterColumn: true,
filters: [],
columnOrAlias: '',
type: null,
columns : @json($results['columns']),
stringCondition: null,
booleanCondition: null,
numberCondition: null,
datetimeCondition: null,
stringValue: null,
booleanValue: null,
datetimeValue: '2000-01-01',
numberValue: 0,
stringConditionSelect: false,
booleanConditionSelect: false,
numberConditionSelect: false,
datetimeConditionSelect: false
}
},
mounted: function() {
this.setParamsAndUrl();
},
methods: {
getColumnOrAlias(columnOrAlias) {
getColumnOrAlias: function(columnOrAlias) {
this.columnOrAlias = columnOrAlias;
for(column in this.columns) {
@ -317,14 +319,14 @@
}
},
nullify() {
nullify: function() {
this.stringCondition = null;
this.datetimeCondition = null;
this.booleanCondition = null;
this.numberCondition = null;
},
getResponse() {
getResponse: function() {
label = '';
for(colIndex in this.columns) {
@ -354,7 +356,7 @@
}
},
sortCollection(alias) {
sortCollection: function(alias) {
label = '';
for(colIndex in this.columns) {
@ -367,14 +369,14 @@
this.formURL("sort", alias, this.sortAsc, label);
},
searchCollection(searchValue) {
searchCollection: function(searchValue) {
label = 'Search';
this.formURL("search", 'all', searchValue, label);
},
// function triggered to check whether the query exists or not and then call the make filters from the url
setParamsAndUrl() {
setParamsAndUrl: function() {
params = (new URL(window.location.href)).search;
if (params.slice(1, params.length).length > 0) {
@ -397,7 +399,7 @@
}
},
findCurrentSort() {
findCurrentSort: function() {
for(i in this.filters) {
if (this.filters[i].column == 'sort') {
this.currentSort = this.filters[i].val;
@ -411,7 +413,7 @@
}
},
changeMassActionTarget() {
changeMassActionTarget: function() {
if (this.massActionType == 'delete') {
for(i in this.massActionTargets) {
if (this.massActionTargets[i].type == 'delete') {
@ -436,7 +438,7 @@
},
//make array of filters, sort and search
formURL(column, condition, response, label) {
formURL: function(column, condition, response, label) {
var obj = {};
if (column == "" || condition == "" || response == "" || column == null || condition == null || response == null) {
@ -577,7 +579,7 @@
},
// make the url from the array and redirect
makeURL() {
makeURL: function() {
newParams = '';
for(i = 0; i < this.filters.length; i++) {
@ -596,7 +598,7 @@
},
//make the filter array from url after being redirected
arrayFromUrl() {
arrayFromUrl: function() {
var obj = {};
processedUrl = this.url.search.slice(1, this.url.length);
splitted = [];
@ -655,7 +657,7 @@
}
},
removeFilter(filter) {
removeFilter: function(filter) {
for(i in this.filters) {
if (this.filters[i].col == filter.col && this.filters[i].cond == filter.cond && this.filters[i].val == filter.val) {
this.filters.splice(i, 1);
@ -666,7 +668,7 @@
},
//triggered when any select box is clicked in the datagrid
select() {
select: function() {
this.allSelected = false;
if(this.dataIds.length == 0)
@ -676,7 +678,7 @@
},
//triggered when master checkbox is clicked
selectAll() {
selectAll: function() {
this.dataIds = [];
this.massActionsToggle = true;
@ -708,7 +710,7 @@
}
},
doAction(e) {
doAction: function(e) {
var element = e.currentTarget;
if (confirm('{{__('ui::app.datagrid.massaction.delete') }}')) {
@ -728,7 +730,7 @@
}
},
removeMassActions() {
removeMassActions: function() {
this.dataIds = [];
this.massActionsToggle = false;