diff --git a/composer.json b/composer.json index 385ff7ad7..436cc38bd 100755 --- a/composer.json +++ b/composer.json @@ -101,7 +101,8 @@ "Webkul\\CartRule\\": "packages/Webkul/CartRule/src", "Webkul\\Rule\\": "packages/Webkul/Rule/src", "Webkul\\CMS\\": "packages/Webkul/CMS/src", - "Webkul\\Velocity\\": "packages/Webkul/Velocity/src" + "Webkul\\Velocity\\": "packages/Webkul/Velocity/src", + "Webkul\\BookingProduct\\": "packages/Webkul/BookingProduct/src" } }, diff --git a/config/app.php b/config/app.php index 2458eb26e..1aa6d5677 100755 --- a/config/app.php +++ b/config/app.php @@ -267,6 +267,7 @@ return [ Webkul\Rule\Providers\RuleServiceProvider::class, Webkul\CMS\Providers\CMSServiceProvider::class, Webkul\Velocity\Providers\VelocityServiceProvider::class, + Webkul\BookingProduct\Providers\BookingProductServiceProvider::class, ], /* diff --git a/config/concord.php b/config/concord.php index 24c40b47a..e7ec5845e 100755 --- a/config/concord.php +++ b/config/concord.php @@ -21,6 +21,7 @@ return [ \Webkul\User\Providers\ModuleServiceProvider::class, \Webkul\CatalogRule\Providers\ModuleServiceProvider::class, \Webkul\CartRule\Providers\ModuleServiceProvider::class, - \Webkul\CMS\Providers\ModuleServiceProvider::class + \Webkul\CMS\Providers\ModuleServiceProvider::class, + \Webkul\BookingProduct\Providers\ModuleServiceProvider::class ] ]; \ No newline at end of file diff --git a/packages/Webkul/API/Http/Controllers/Shop/AddressController.php b/packages/Webkul/API/Http/Controllers/Shop/AddressController.php index 863710ac0..31b724864 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/AddressController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/AddressController.php @@ -5,12 +5,6 @@ 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 - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AddressController extends Controller { /** @@ -30,18 +24,16 @@ class AddressController extends Controller /** * CustomerAddressRepository object * - * @var Object + * @var \Webkul\Customer\Repositories\CustomerAddressRepository */ protected $customerAddressRepository; /** * Controller instance * - * @param Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository + * @param Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository */ - public function __construct( - CustomerAddressRepository $customerAddressRepository - ) + public function __construct(CustomerAddressRepository $customerAddressRepository) { $this->guard = request()->has('token') ? 'api' : 'customer'; @@ -62,6 +54,7 @@ class AddressController extends Controller public function get() { $customer = auth($this->guard)->user(); + $addresses = $customer->addresses()->get(); return CustomerAddressResource::collection($addresses); @@ -77,25 +70,25 @@ class AddressController extends Controller $customer = auth($this->guard)->user(); request()->merge([ - 'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))), - 'customer_id' => $customer->id + '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', + 'country' => 'string|required', + 'state' => 'string|required', + 'city' => 'string|required', 'postcode' => 'required', - 'phone' => 'required' + 'phone' => 'required', ]); $customerAddress = $this->customerAddressRepository->create(request()->all()); return response()->json([ - 'message' => 'Your address has been created successfully.', - 'data' => new CustomerAddressResource($customerAddress) - ]); + 'message' => 'Your address has been created successfully.', + 'data' => new CustomerAddressResource($customerAddress), + ]); } /** @@ -111,18 +104,18 @@ class AddressController extends Controller $this->validate(request(), [ 'address1' => 'string|required', - 'country' => 'string|required', - 'state' => 'string|required', - 'city' => 'string|required', + 'country' => 'string|required', + 'state' => 'string|required', + 'city' => 'string|required', 'postcode' => 'required', - 'phone' => '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'))) - ]); + 'message' => 'Your address has been updated successfully.', + 'data' => new CustomerAddressResource($this->customerAddressRepository->find(request()->input('id'))), + ]); } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Controllers/Shop/CartController.php b/packages/Webkul/API/Http/Controllers/Shop/CartController.php index 545185a11..c06644456 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CartController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CartController.php @@ -9,12 +9,6 @@ use Webkul\API\Http\Resources\Checkout\Cart as CartResource; use Cart; use Webkul\Customer\Repositories\WishlistRepository; -/** - * Cart controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CartController extends Controller { /** @@ -27,30 +21,30 @@ class CartController extends Controller /** * CartRepository object * - * @var Object + * @var \Webkul\Checkout\Repositories\CartRepository */ protected $cartRepository; /** * CartItemRepository object * - * @var Object + * @var \Webkul\Checkout\Repositories\CartItemRepository */ protected $cartItemRepository; /** * WishlistRepository object * - * @var Object + * @var \Webkul\Checkout\Repositories\WishlistRepository */ protected $wishlistRepository; /** * Controller instance * - * @param Webkul\Checkout\Repositories\CartRepository $cartRepository - * @param Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository - * @param Webkul\Checkout\Repositories\WishlistRepository $wishlistRepository + * @param \Webkul\Checkout\Repositories\CartRepository $cartRepository + * @param \Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository + * @param \Webkul\Checkout\Repositories\WishlistRepository $wishlistRepository */ public function __construct( CartRepository $cartRepository, @@ -84,7 +78,7 @@ class CartController extends Controller $cart = Cart::getCart(); return response()->json([ - 'data' => $cart ? new CartResource($cart) : null + 'data' => $cart ? new CartResource($cart) : null, ]); } @@ -92,8 +86,7 @@ class CartController extends Controller /** * Store a newly created resource in storage. * - * @param int $id - * + * @param int $id * @return \Illuminate\Http\Response */ public function store($id) @@ -110,7 +103,7 @@ class CartController extends Controller $message = session()->get('warning') ?? session()->get('error'); return response()->json([ - 'error' => session()->get('warning') + 'error' => session()->get('warning'), ], 400); } @@ -126,7 +119,7 @@ class CartController extends Controller return response()->json([ 'message' => __('shop::app.checkout.cart.item.success'), - 'data' => $cart ? new CartResource($cart) : null + 'data' => $cart ? new CartResource($cart) : null, ]); } @@ -140,7 +133,7 @@ class CartController extends Controller foreach (request()->get('qty') as $qty) { if ($qty <= 0) { return response()->json([ - 'message' => trans('shop::app.checkout.cart.quantity.illegal') + 'message' => trans('shop::app.checkout.cart.quantity.illegal'), ], 401); } } @@ -161,7 +154,7 @@ class CartController extends Controller return response()->json([ 'message' => __('shop::app.checkout.cart.quantity.success'), - 'data' => $cart ? new CartResource($cart) : null + 'data' => $cart ? new CartResource($cart) : null, ]); } @@ -182,15 +175,14 @@ class CartController extends Controller return response()->json([ 'message' => __('shop::app.checkout.cart.item.success-remove'), - 'data' => $cart ? new CartResource($cart) : null + 'data' => $cart ? new CartResource($cart) : null, ]); } /** * Remove the specified resource from storage. * - * @param int $id - * + * @param int $id * @return \Illuminate\Http\Response */ public function destroyItem($id) @@ -207,15 +199,14 @@ class CartController extends Controller return response()->json([ 'message' => __('shop::app.checkout.cart.item.success-remove'), - 'data' => $cart ? new CartResource($cart) : null + 'data' => $cart ? new CartResource($cart) : null, ]); } /** - * Function to move a already added product to wishlist - * will run only on customer authentication. + * Function to move a already added product to wishlist will run only on customer authentication. * - * @param instance cartItem $id + * @param \Webkul\Checkout\Repositories\CartItemRepository $id */ public function moveToWishlist($id) { @@ -231,7 +222,7 @@ class CartController extends Controller return response()->json([ 'message' => __('shop::app.checkout.cart.move-to-wishlist-success'), - 'data' => $cart ? new CartResource($cart) : null + 'data' => $cart ? new CartResource($cart) : null, ]); } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Controllers/Shop/CategoryController.php b/packages/Webkul/API/Http/Controllers/Shop/CategoryController.php index 19a5b2390..34e0a6bb0 100755 --- a/packages/Webkul/API/Http/Controllers/Shop/CategoryController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CategoryController.php @@ -6,25 +6,19 @@ use Illuminate\Http\Request; use Webkul\Category\Repositories\CategoryRepository; use Webkul\API\Http\Resources\Catalog\Category as CategoryResource; -/** - * Category controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CategoryController extends Controller { /** * CategoryRepository object * - * @var array + * @var \Webkul\Category\Repositories\CategoryRepository */ protected $categoryRepository; /** * Create a new controller instance. * - * @param Webkul\Category\Repositories\CategoryRepository $categoryRepository + * @param Webkul\Category\Repositories\CategoryRepository $categoryRepository * @return void */ public function __construct(CategoryRepository $categoryRepository) @@ -40,7 +34,7 @@ class CategoryController extends Controller public function index() { return CategoryResource::collection( - $this->categoryRepository->getVisibleCategoryTree(request()->input('parent_id')) - ); + $this->categoryRepository->getVisibleCategoryTree(request()->input('parent_id')) + ); } } diff --git a/packages/Webkul/API/Http/Controllers/Shop/CheckoutController.php b/packages/Webkul/API/Http/Controllers/Shop/CheckoutController.php index bfd49f637..0915d73d2 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CheckoutController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CheckoutController.php @@ -15,12 +15,6 @@ use Webkul\Sales\Repositories\OrderRepository; use Illuminate\Support\Str; use Cart; -/** - * Checkout controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CheckoutController extends Controller { /** @@ -33,23 +27,23 @@ class CheckoutController extends Controller /** * CartRepository object * - * @var Object + * @var \Webkul\Checkout\Repositories\CartRepository */ protected $cartRepository; /** * CartItemRepository object * - * @var Object + * @var \Webkul\Checkout\Repositories\CartItemRepository */ protected $cartItemRepository; /** * Controller instance * - * @param Webkul\Checkout\Repositories\CartRepository $cartRepository - * @param Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository - * @param Webkul\Sales\Repositories\OrderRepository $orderRepository + * @param \Webkul\Checkout\Repositories\CartRepository $cartRepository + * @param \Webkul\Checkout\Repositories\CartItemRepository $cartItemRepository + * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository */ public function __construct( CartRepository $cartRepository, @@ -61,7 +55,6 @@ class CheckoutController extends Controller auth()->setDefaultDriver($this->guard); - // $this->middleware('auth:' . $this->guard); $this->_config = request('_config'); @@ -84,6 +77,7 @@ class CheckoutController extends Controller $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_')) { @@ -97,15 +91,16 @@ class CheckoutController extends Controller } - if (Cart::hasError() || ! Cart::saveCustomerAddress($data) || ! Shipping::collectRates()) + 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'])) + 'rates' => CartShippingRateResource::collection(collect($shippingMethod['rates'])), ]; } @@ -114,7 +109,7 @@ class CheckoutController extends Controller return response()->json([ 'data' => [ 'rates' => $rates, - 'cart' => new CartResource(Cart::getCart()) + 'cart' => new CartResource(Cart::getCart()), ] ]); } @@ -128,15 +123,19 @@ class CheckoutController extends Controller { $shippingMethod = request()->get('shipping_method'); - if (Cart::hasError() || !$shippingMethod || ! Cart::saveShippingMethod($shippingMethod)) + if (Cart::hasError() + || !$shippingMethod + || ! Cart::saveShippingMethod($shippingMethod) + ) { abort(400); + } Cart::collectTotals(); return response()->json([ 'data' => [ 'methods' => Payment::getPaymentMethods(), - 'cart' => new CartResource(Cart::getCart()) + 'cart' => new CartResource(Cart::getCart()), ] ]); } @@ -150,12 +149,13 @@ class CheckoutController extends Controller { $payment = request()->get('payment'); - if (Cart::hasError() || ! $payment || ! Cart::savePaymentMethod($payment)) + if (Cart::hasError() || ! $payment || ! Cart::savePaymentMethod($payment)) { abort(400); + } return response()->json([ 'data' => [ - 'cart' => new CartResource(Cart::getCart()) + 'cart' => new CartResource(Cart::getCart()), ] ]); } @@ -167,8 +167,9 @@ class CheckoutController extends Controller */ public function saveOrder() { - if (Cart::hasError()) + if (Cart::hasError()) { abort(400); + } Cart::collectTotals(); @@ -178,8 +179,8 @@ class CheckoutController extends Controller if ($redirectUrl = Payment::getRedirectUrl($cart)) { return response()->json([ - 'success' => true, - 'redirect_url' => $redirectUrl + 'success' => true, + 'redirect_url' => $redirectUrl, ]); } @@ -188,9 +189,9 @@ class CheckoutController extends Controller Cart::deActivateCart(); return response()->json([ - 'success' => true, - 'order' => new OrderResource($order), - ]); + 'success' => true, + 'order' => new OrderResource($order), + ]); } /** diff --git a/packages/Webkul/API/Http/Controllers/Shop/CoreController.php b/packages/Webkul/API/Http/Controllers/Shop/CoreController.php index 27290bdcd..9d76fee63 100755 --- a/packages/Webkul/API/Http/Controllers/Shop/CoreController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CoreController.php @@ -4,12 +4,6 @@ namespace Webkul\API\Http\Controllers\Shop; use Illuminate\Http\Request; -/** - * Core controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CoreController extends Controller { /** @@ -26,7 +20,7 @@ class CoreController extends Controller } return response()->json([ - 'data' => $configValues + 'data' => $configValues, ]); } @@ -38,7 +32,7 @@ class CoreController extends Controller public function getCountryStateGroup() { return response()->json([ - 'data' => core()->groupedStatesByCountries() + 'data' => core()->groupedStatesByCountries(), ]); } diff --git a/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php b/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php index c32816dbb..222898993 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php @@ -6,13 +6,6 @@ use Illuminate\Support\Facades\Event; use Webkul\Customer\Repositories\CustomerRepository; use Webkul\Customer\Repositories\CustomerGroupRepository; -/** - * Customer controller - * - * @author Jitendra Singh - * @author Vivek Sharma @vivek-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CustomerController extends Controller { /** @@ -25,22 +18,22 @@ class CustomerController extends Controller /** * Repository object * - * @var array + * @var \Webkul\Customer\Repositories\CustomerRepository */ protected $customerRepository; /** * Repository object * - * @var array + * @var \Webkul\Customer\Repositories\CustomerGroupRepository */ protected $customerGroupRepository; /** * Create a new controller instance. * - * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository - * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository + * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository + * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository * @return void */ public function __construct( @@ -57,23 +50,23 @@ class CustomerController extends Controller /** * Method to store user's sign up form data to DB. * - * @return Mixed + * @return \Illuminate\Http\Response */ public function create() { request()->validate([ 'first_name' => 'required', - 'last_name' => 'required', - 'email' => 'email|required|unique:customers,email', - 'password' => 'confirmed|min:6|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 + 'password' => bcrypt($data['password']), + 'channel_id' => core()->getCurrentChannel()->id, + 'is_verified' => 1, ]); $data['customer_group_id'] = $this->customerGroupRepository->findOneWhere(['code' => 'general'])->id; @@ -85,7 +78,7 @@ class CustomerController extends Controller Event::dispatch('customer.registration.after', $customer); return response()->json([ - 'message' => 'Your account has been created successfully.' - ]); + 'message' => 'Your account has been created successfully.', + ]); } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php b/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php index 50529541e..c485e2b70 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php @@ -5,12 +5,6 @@ namespace Webkul\API\Http\Controllers\Shop; use Illuminate\Foundation\Auth\SendsPasswordResetEmails; use Illuminate\Support\Facades\Password; -/** - * Forgot Password controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ForgotPasswordController extends Controller { use SendsPasswordResetEmails; @@ -23,20 +17,20 @@ class ForgotPasswordController extends Controller public function store() { $this->validate(request(), [ - 'email' => 'required|email' + 'email' => 'required|email', ]); $response = $this->broker()->sendResetLink(request(['email'])); if ($response == Password::RESET_LINK_SENT) { return response()->json([ - 'message' => trans($response) - ]); + 'message' => trans($response), + ]); } return response()->json([ - 'error' => trans($response) - ]); + 'error' => trans($response), + ]); } /** diff --git a/packages/Webkul/API/Http/Controllers/Shop/ProductController.php b/packages/Webkul/API/Http/Controllers/Shop/ProductController.php index 3f7c4acce..051982e51 100755 --- a/packages/Webkul/API/Http/Controllers/Shop/ProductController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ProductController.php @@ -7,25 +7,19 @@ use Illuminate\Http\Response; use Webkul\Product\Repositories\ProductRepository; use Webkul\API\Http\Resources\Catalog\Product as ProductResource; -/** - * Product controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ProductController extends Controller { /** * ProductRepository object * - * @var array + * @var \Webkul\Product\Repositories\ProductRepository */ protected $productRepository; /** * Create a new controller instance. * - * @param Webkul\Product\Repositories\ProductRepository $productRepository + * @param \Webkul\Product\Repositories\ProductRepository $productRepository * @return void */ public function __construct(ProductRepository $productRepository) @@ -46,36 +40,39 @@ class ProductController extends Controller /** * Returns a individual resource. * + * @param int $id * @return \Illuminate\Http\Response */ public function get($id) { return new ProductResource( - $this->productRepository->findOrFail($id) - ); + $this->productRepository->findOrFail($id) + ); } /** * Returns product's additional information. * + * @param int $id * @return \Illuminate\Http\Response */ public function additionalInformation($id) { return response()->json([ - 'data' => app('Webkul\Product\Helpers\View')->getAdditionalData($this->productRepository->findOrFail($id)) - ]); + 'data' => app('Webkul\Product\Helpers\View')->getAdditionalData($this->productRepository->findOrFail($id)), + ]); } /** * Returns product's additional information. * + * @param int $id * @return \Illuminate\Http\Response */ public function configurableConfig($id) { return response()->json([ - 'data' => app('Webkul\Product\Helpers\ConfigurableOption')->getConfigurationConfig($this->productRepository->findOrFail($id)) - ]); + 'data' => app('Webkul\Product\Helpers\ConfigurableOption')->getConfigurationConfig($this->productRepository->findOrFail($id)), + ]); } } diff --git a/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php b/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php index 2fdd8b859..5668bd64a 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php @@ -4,12 +4,6 @@ namespace Webkul\API\Http\Controllers\Shop; use Illuminate\Http\Request; -/** - * Resource Controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ResourceController extends Controller { /** @@ -29,7 +23,7 @@ class ResourceController extends Controller /** * Repository object * - * @var array + * @var \Webkul\Core\Eloquent\Repository */ protected $repository; @@ -87,18 +81,20 @@ class ResourceController extends Controller /** * Returns a individual resource. * + * @param int $id * @return \Illuminate\Http\Response */ public function get($id) { return new $this->_config['resource']( - $this->repository->findOrFail($id) - ); + $this->repository->findOrFail($id) + ); } /** * Delete's a individual resource. * + * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) @@ -108,7 +104,7 @@ class ResourceController extends Controller $this->repository->delete($id); return response()->json([ - 'message' => 'Item removed successfully.' - ]); + 'message' => 'Item removed successfully.', + ]); } } diff --git a/packages/Webkul/API/Http/Controllers/Shop/ReviewController.php b/packages/Webkul/API/Http/Controllers/Shop/ReviewController.php index 5121628be..2a5653ce3 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/ReviewController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ReviewController.php @@ -6,12 +6,6 @@ use Illuminate\Http\Request; use Webkul\Product\Repositories\ProductReviewRepository; use Webkul\API\Http\Resources\Catalog\ProductReview as ProductReviewResource; -/** - * Review controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ReviewController extends Controller { /** @@ -24,14 +18,14 @@ class ReviewController extends Controller /** * ProductReviewRepository object * - * @var array + * @var \Webkul\Product\Repositories\ProductReviewRepository */ protected $reviewRepository; /** * Controller instance * - * @param Webkul\Product\Repositories\ProductReviewRepository $reviewRepository + * @param Webkul\Product\Repositories\ProductReviewRepository $reviewRepository */ public function __construct(ProductReviewRepository $reviewRepository) { @@ -46,6 +40,7 @@ class ReviewController extends Controller * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request + * @param int $id * @return \Illuminate\Http\Response */ public function store(Request $request, $id) @@ -60,16 +55,16 @@ class ReviewController extends Controller $data = array_merge(request()->all(), [ 'customer_id' => $customer ? $customer->id : null, - 'name' => $customer ? $customer->name : request()->input('name'), - 'status' => 'pending', - 'product_id' => $id + '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)) - ]); + 'message' => 'Your review submitted successfully.', + 'data' => new ProductReviewResource($this->reviewRepository->find($productReview->id)), + ]); } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Controllers/Shop/SessionController.php b/packages/Webkul/API/Http/Controllers/Shop/SessionController.php index 714d67efe..19370d917 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/SessionController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/SessionController.php @@ -6,18 +6,12 @@ use Illuminate\Support\Facades\Event; use Webkul\Customer\Repositories\CustomerRepository; use Webkul\API\Http\Resources\Customer\Customer as CustomerResource; -/** - * Session controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class SessionController extends Controller { /** * Contains current guard * - * @var array + * @var string */ protected $guard; @@ -31,7 +25,7 @@ class SessionController extends Controller /** * Controller instance * - * @param Webkul\Customer\Repositories\CustomerRepository $customerRepository + * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository */ public function __construct(CustomerRepository $customerRepository) { @@ -49,13 +43,13 @@ class SessionController extends Controller /** * Method to store user's sign up form data to DB. * - * @return Mixed + * @return \Illuminate\Http\Response */ public function create() { request()->validate([ - 'email' => 'required|email', - 'password' => 'required' + 'email' => 'required|email', + 'password' => 'required', ]); $jwtToken = null; @@ -71,9 +65,9 @@ class SessionController extends Controller $customer = auth($this->guard)->user(); return response()->json([ - 'token' => $jwtToken, + 'token' => $jwtToken, 'message' => 'Logged in successfully.', - 'data' => new CustomerResource($customer) + 'data' => new CustomerResource($customer), ]); } @@ -87,7 +81,7 @@ class SessionController extends Controller $customer = auth($this->guard)->user(); return response()->json([ - 'data' => new CustomerResource($customer) + 'data' => new CustomerResource($customer), ]); } @@ -101,12 +95,12 @@ class SessionController extends Controller $customer = auth($this->guard)->user(); $this->validate(request(), [ - 'first_name' => 'required', - 'last_name' => 'required', - 'gender' => 'required', + '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' + 'email' => 'email|unique:customers,email,' . $customer->id, + 'password' => 'confirmed|min:6', ]); $data = request()->all(); @@ -124,9 +118,9 @@ class SessionController extends Controller $this->customerRepository->update($data, $customer->id); return response()->json([ - 'message' => 'Your account has been created successfully.', - 'data' => new CustomerResource($this->customerRepository->find($customer->id)) - ]); + 'message' => 'Your account has been created successfully.', + 'data' => new CustomerResource($this->customerRepository->find($customer->id)), + ]); } /** diff --git a/packages/Webkul/API/Http/Controllers/Shop/WishlistController.php b/packages/Webkul/API/Http/Controllers/Shop/WishlistController.php index be3eeb84f..5682abbb5 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/WishlistController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/WishlistController.php @@ -9,31 +9,25 @@ use Webkul\API\Http\Resources\Customer\Wishlist as WishlistResource; use Webkul\API\Http\Resources\Checkout\Cart as CartResource; use Cart; -/** - * Wishlist controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class WishlistController extends Controller { /** * WishlistRepository object * - * @var object + * @var \Webkul\Customer\Repositories\WishlistRepository */ protected $wishlistRepository; /** * ProductRepository object * - * @var object + * @var \Webkul\Customer\Repositories\ProductRepository */ protected $productRepository; /** - * @param Webkul\Customer\Repositories\WishlistRepository $wishlistRepository - * @param Webkul\Product\Repositories\ProductRepository $productRepository + * @param \Webkul\Customer\Repositories\WishlistRepository $wishlistRepository + * @param \Webkul\Product\Repositories\ProductRepository $productRepository */ public function __construct( WishlistRepository $wishlistRepository, @@ -54,7 +48,7 @@ class WishlistController extends Controller /** * Function to add item to the wishlist. * - * @param integer $id + * @param int $id * @return \Illuminate\Http\Response */ public function create($id) @@ -64,46 +58,47 @@ class WishlistController extends Controller $customer = auth()->guard($this->guard)->user(); $wishlistItem = $this->wishlistRepository->findOneWhere([ - 'channel_id' => core()->getCurrentChannel()->id, - 'product_id' => $id, - 'customer_id' => $customer->id - ]); + '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 - ]); + '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') - ]); + '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.' - ]); + 'data' => null, + 'message' => 'Item removed from wishlist successfully.', + ]); } } /** * Move product from wishlist to cart. * - * @param integer $id + * @param int $id * @return \Illuminate\Http\Response */ public function moveToCart($id) { $wishlistItem = $this->wishlistRepository->findOrFail($id); - if ($wishlistItem->customer_id != auth()->guard($this->guard)->user()->id) + if ($wishlistItem->customer_id != auth()->guard($this->guard)->user()->id) { return response()->json([ - 'message' => trans('shop::app.security-warning') - ], 400); + 'message' => trans('shop::app.security-warning'), + ], 400); + } $result = Cart::moveToCart($wishlistItem); @@ -113,14 +108,14 @@ class WishlistController extends Controller $cart = Cart::getCart(); return response()->json([ - 'data' => $cart ? new CartResource($cart) : null, - 'message' => trans('shop::app.wishlist.moved') - ]); + 'data' => $cart ? new CartResource($cart) : null, + 'message' => trans('shop::app.wishlist.moved'), + ]); } else { return response()->json([ - 'data' => -1, - 'error' => trans('shop::app.wishlist.option-missing') - ], 400); + 'data' => -1, + 'error' => trans('shop::app.wishlist.option-missing'), + ], 400); } } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Catalog/Attribute.php b/packages/Webkul/API/Http/Resources/Catalog/Attribute.php index 098b93f12..ca65e863e 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/Attribute.php +++ b/packages/Webkul/API/Http/Resources/Catalog/Attribute.php @@ -15,14 +15,14 @@ class Attribute extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'code' => $this->code, - 'type' => $this->type, - 'name' => $this->name, + 'id' => $this->id, + 'code' => $this->code, + 'type' => $this->type, + 'name' => $this->name, 'swatch_type' => $this->swatch_type, - 'options' => AttributeOption::collection($this->options), - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, + 'options' => AttributeOption::collection($this->options), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Catalog/AttributeFamily.php b/packages/Webkul/API/Http/Resources/Catalog/AttributeFamily.php index 6c6743531..0bd64e3c0 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/AttributeFamily.php +++ b/packages/Webkul/API/Http/Resources/Catalog/AttributeFamily.php @@ -15,11 +15,11 @@ class AttributeFamily extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'code' => $this->code, - 'name' => $this->name, - 'status' => $this->status, - 'groups' => AttributeGroup::collection($this->attribute_groups), + 'id' => $this->id, + 'code' => $this->code, + 'name' => $this->name, + 'status' => $this->status, + 'groups' => AttributeGroup::collection($this->attribute_groups), 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; diff --git a/packages/Webkul/API/Http/Resources/Catalog/AttributeGroup.php b/packages/Webkul/API/Http/Resources/Catalog/AttributeGroup.php index 81fbfbf8e..cc41c9fd1 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/AttributeGroup.php +++ b/packages/Webkul/API/Http/Resources/Catalog/AttributeGroup.php @@ -15,11 +15,11 @@ class AttributeGroup extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'code' => $this->code, - 'name' => $this->name, + 'id' => $this->id, + 'code' => $this->code, + 'name' => $this->name, 'swatch_type' => $this->swatch_type, - 'attributes' => Attribute::collection($this->custom_attributes) + 'attributes' => Attribute::collection($this->custom_attributes) ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Catalog/AttributeOption.php b/packages/Webkul/API/Http/Resources/Catalog/AttributeOption.php index ff4f21e8e..e0a9a8a5e 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/AttributeOption.php +++ b/packages/Webkul/API/Http/Resources/Catalog/AttributeOption.php @@ -15,9 +15,9 @@ class AttributeOption extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'admin_name' => $this->admin_name, - 'label' => $this->label, + 'id' => $this->id, + 'admin_name' => $this->admin_name, + 'label' => $this->label, 'swatch_value' => $this->swatch_value ]; } diff --git a/packages/Webkul/API/Http/Resources/Catalog/Category.php b/packages/Webkul/API/Http/Resources/Catalog/Category.php index 2ecb649ac..f99af8723 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/Category.php +++ b/packages/Webkul/API/Http/Resources/Catalog/Category.php @@ -15,19 +15,19 @@ class Category extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'code' => $this->code, - 'name' => $this->name, - 'slug' => $this->slug, - 'display_mode' => $this->display_mode, - 'description' => $this->description, - 'meta_title' => $this->meta_title, + 'id' => $this->id, + '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, - 'meta_keywords' => $this->meta_keywords, - 'status' => $this->status, - 'image_url' => $this->image_url, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, + 'meta_keywords' => $this->meta_keywords, + 'status' => $this->status, + 'image_url' => $this->image_url, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Catalog/Product.php b/packages/Webkul/API/Http/Resources/Catalog/Product.php index c4a1ec895..e81a7b872 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/Product.php +++ b/packages/Webkul/API/Http/Resources/Catalog/Product.php @@ -32,23 +32,23 @@ class Product extends JsonResource $product = $this->product ? $this->product : $this; return [ - 'id' => $product->id, - 'type' => $product->type, - 'name' => $this->name, - 'url_key' => $this->url_key, - 'price' => $product->getTypeInstance()->getMinimalPrice(), - 'formated_price' => core()->currency($product->getTypeInstance()->getMinimalPrice()), - '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), + 'id' => $product->id, + 'type' => $product->type, + 'name' => $this->name, + 'url_key' => $this->url_key, + 'price' => $product->getTypeInstance()->getMinimalPrice(), + 'formated_price' => core()->currency($product->getTypeInstance()->getMinimalPrice()), + '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), $this->mergeWhen($product->getTypeInstance()->isComposite(), [ 'super_attributes' => Attribute::collection($product->super_attributes), ]), - 'special_price' => $this->when( + 'special_price' => $this->when( $product->getTypeInstance()->haveSpecialPrice(), $product->getTypeInstance()->getSpecialPrice() ), @@ -56,15 +56,15 @@ class Product extends JsonResource $product->getTypeInstance()->haveSpecialPrice(), core()->currency($product->getTypeInstance()->getSpecialPrice()) ), - 'reviews' => [ - 'total' => $total = $this->productReviewHelper->getTotalReviews($product), - 'total_rating' => $total ? $this->productReviewHelper->getTotalRating($product) : 0, + '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)) : [], + 'percentage' => $total ? json_encode($this->productReviewHelper->getPercentageRating($product)) : [], ], - 'is_saved' => false, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, + 'is_saved' => false, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Catalog/ProductImage.php b/packages/Webkul/API/Http/Resources/Catalog/ProductImage.php index cd4e574bf..a704b8ff6 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/ProductImage.php +++ b/packages/Webkul/API/Http/Resources/Catalog/ProductImage.php @@ -15,13 +15,13 @@ class ProductImage extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'path' => $this->path, - 'url' => $this->url, + '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) + 'small_image_url' => url('cache/small/' . $this->path), + 'medium_image_url' => url('cache/medium/' . $this->path), + 'large_image_url' => url('cache/large/' . $this->path) ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Catalog/ProductReview.php b/packages/Webkul/API/Http/Resources/Catalog/ProductReview.php index a2902b598..94e37820b 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/ProductReview.php +++ b/packages/Webkul/API/Http/Resources/Catalog/ProductReview.php @@ -16,14 +16,14 @@ class ProductReview extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'title' => $this->title, - 'rating' => number_format($this->rating, 1, '.', ''), - 'comment' => $this->comment, - 'name' => $this->name, - 'status' => $this->status, - 'product' => new Product($this->product), - 'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)), + 'id' => $this->id, + 'title' => $this->title, + 'rating' => number_format($this->rating, 1, '.', ''), + 'comment' => $this->comment, + 'name' => $this->name, + 'status' => $this->status, + 'product' => new Product($this->product), + 'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)), 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; diff --git a/packages/Webkul/API/Http/Resources/Checkout/Cart.php b/packages/Webkul/API/Http/Resources/Checkout/Cart.php index 028d42f43..041937f2d 100644 --- a/packages/Webkul/API/Http/Resources/Checkout/Cart.php +++ b/packages/Webkul/API/Http/Resources/Checkout/Cart.php @@ -24,52 +24,52 @@ class Cart extends JsonResource 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, + '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, - 'taxes' => json_encode($taxes, JSON_FORCE_OBJECT), - 'formated_taxes' => json_encode($formatedTaxes, JSON_FORCE_OBJECT), - 'base_taxes' => json_encode($baseTaxes, JSON_FORCE_OBJECT), - 'formated_base_taxes' => json_encode($formatedBaseTaxes, JSON_FORCE_OBJECT), + '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, + 'taxes' => json_encode($taxes, JSON_FORCE_OBJECT), + 'formated_taxes' => json_encode($formatedTaxes, JSON_FORCE_OBJECT), + 'base_taxes' => json_encode($baseTaxes, JSON_FORCE_OBJECT), + 'formated_base_taxes' => json_encode($formatedBaseTaxes, JSON_FORCE_OBJECT), ]; } diff --git a/packages/Webkul/API/Http/Resources/Checkout/CartAddress.php b/packages/Webkul/API/Http/Resources/Checkout/CartAddress.php index 1bed8697c..0ff7f7987 100644 --- a/packages/Webkul/API/Http/Resources/Checkout/CartAddress.php +++ b/packages/Webkul/API/Http/Resources/Checkout/CartAddress.php @@ -16,19 +16,19 @@ class CartAddress extends JsonResource { 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, + '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' => core()->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, + 'state' => $this->state, + 'city' => $this->city, + 'postcode' => $this->postcode, + 'phone' => $this->phone, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Checkout/CartItem.php b/packages/Webkul/API/Http/Resources/Checkout/CartItem.php index 37c36684e..9f3418734 100644 --- a/packages/Webkul/API/Http/Resources/Checkout/CartItem.php +++ b/packages/Webkul/API/Http/Resources/Checkout/CartItem.php @@ -16,42 +16,42 @@ class CartItem extends JsonResource 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, + '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, + '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, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Checkout/CartPayment.php b/packages/Webkul/API/Http/Resources/Checkout/CartPayment.php index 8ab0c28ac..530144708 100644 --- a/packages/Webkul/API/Http/Resources/Checkout/CartPayment.php +++ b/packages/Webkul/API/Http/Resources/Checkout/CartPayment.php @@ -15,11 +15,11 @@ class CartPayment extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'method' => $this->method, + '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 + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Checkout/CartShippingRate.php b/packages/Webkul/API/Http/Resources/Checkout/CartShippingRate.php index 370697be5..bb0204672 100644 --- a/packages/Webkul/API/Http/Resources/Checkout/CartShippingRate.php +++ b/packages/Webkul/API/Http/Resources/Checkout/CartShippingRate.php @@ -18,18 +18,18 @@ class CartShippingRate extends JsonResource $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, + '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 + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Core/Channel.php b/packages/Webkul/API/Http/Resources/Core/Channel.php index e85085ce0..4298e3b44 100644 --- a/packages/Webkul/API/Http/Resources/Core/Channel.php +++ b/packages/Webkul/API/Http/Resources/Core/Channel.php @@ -18,25 +18,25 @@ class Channel extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'code' => $this->code, - 'name' => $this->name, - 'description' => $this->description, - 'timezone' => $this->timezone, - 'theme' => $this->theme, + 'id' => $this->id, + 'code' => $this->code, + 'name' => $this->name, + 'description' => $this->description, + 'timezone' => $this->timezone, + 'theme' => $this->theme, 'home_page_content' => $this->home_page_content, - 'footer_content' => $this->footer_content, - 'hostname' => $this->hostname, - 'logo' => $this->logo, - 'logo_url' => $this->logo_url, - 'favicon' => $this->favicon, - '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, + 'footer_content' => $this->footer_content, + 'hostname' => $this->hostname, + 'logo' => $this->logo, + 'logo_url' => $this->logo_url, + 'favicon' => $this->favicon, + '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, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Core/Country.php b/packages/Webkul/API/Http/Resources/Core/Country.php index 46f13f0c1..92c18cb17 100644 --- a/packages/Webkul/API/Http/Resources/Core/Country.php +++ b/packages/Webkul/API/Http/Resources/Core/Country.php @@ -15,7 +15,7 @@ class Country extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, + 'id' => $this->id, 'code' => $this->code, 'name' => $this->name ]; diff --git a/packages/Webkul/API/Http/Resources/Core/Currency.php b/packages/Webkul/API/Http/Resources/Core/Currency.php index 5ef066daa..dd8169ec6 100644 --- a/packages/Webkul/API/Http/Resources/Core/Currency.php +++ b/packages/Webkul/API/Http/Resources/Core/Currency.php @@ -15,9 +15,9 @@ class Currency extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'code' => $this->code, - 'name' => $this->name, + 'id' => $this->id, + 'code' => $this->code, + 'name' => $this->name, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; diff --git a/packages/Webkul/API/Http/Resources/Core/Locale.php b/packages/Webkul/API/Http/Resources/Core/Locale.php index 21e5e4399..9cdd7c8e8 100644 --- a/packages/Webkul/API/Http/Resources/Core/Locale.php +++ b/packages/Webkul/API/Http/Resources/Core/Locale.php @@ -15,9 +15,9 @@ class Locale extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'code' => $this->code, - 'name' => $this->name, + 'id' => $this->id, + 'code' => $this->code, + 'name' => $this->name, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; diff --git a/packages/Webkul/API/Http/Resources/Core/Slider.php b/packages/Webkul/API/Http/Resources/Core/Slider.php index fada15f9b..76bf0fc37 100644 --- a/packages/Webkul/API/Http/Resources/Core/Slider.php +++ b/packages/Webkul/API/Http/Resources/Core/Slider.php @@ -15,10 +15,10 @@ class Slider extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'title' => $this->title, + 'id' => $this->id, + 'title' => $this->title, 'image_url' => $this->image_url, - 'content' => $this->content + 'content' => $this->content ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Customer/Customer.php b/packages/Webkul/API/Http/Resources/Customer/Customer.php index 7e7a98485..31f1a3b5f 100644 --- a/packages/Webkul/API/Http/Resources/Customer/Customer.php +++ b/packages/Webkul/API/Http/Resources/Customer/Customer.php @@ -15,18 +15,18 @@ class Customer extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'email' => $this->email, - 'first_name' => $this->first_name, - 'last_name' => $this->last_name, - 'name' => $this->name, - 'gender' => $this->gender, + 'id' => $this->id, + 'email' => $this->email, + 'first_name' => $this->first_name, + 'last_name' => $this->last_name, + 'name' => $this->name, + 'gender' => $this->gender, 'date_of_birth' => $this->date_of_birth, - 'phone' => $this->phone, - 'status' => $this->status, - 'group' => $this->when($this->customer_group_id, new CustomerGroup($this->group)), - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, + 'phone' => $this->phone, + 'status' => $this->status, + 'group' => $this->when($this->customer_group_id, new CustomerGroup($this->group)), + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Customer/CustomerAddress.php b/packages/Webkul/API/Http/Resources/Customer/CustomerAddress.php index 3b792e195..111cdb31c 100644 --- a/packages/Webkul/API/Http/Resources/Customer/CustomerAddress.php +++ b/packages/Webkul/API/Http/Resources/Customer/CustomerAddress.php @@ -15,16 +15,16 @@ class CustomerAddress extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'address1' => explode(PHP_EOL, $this->address1), - 'country' => $this->country, + 'id' => $this->id, + 'address1' => explode(PHP_EOL, $this->address1), + 'country' => $this->country, 'country_name' => core()->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, + 'state' => $this->state, + 'city' => $this->city, + 'postcode' => $this->postcode, + 'phone' => $this->phone, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Customer/CustomerGroup.php b/packages/Webkul/API/Http/Resources/Customer/CustomerGroup.php index 80765deb2..fdda10af0 100644 --- a/packages/Webkul/API/Http/Resources/Customer/CustomerGroup.php +++ b/packages/Webkul/API/Http/Resources/Customer/CustomerGroup.php @@ -15,8 +15,8 @@ class CustomerGroup extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'name' => $this->name, + 'id' => $this->id, + 'name' => $this->name, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; diff --git a/packages/Webkul/API/Http/Resources/Customer/Wishlist.php b/packages/Webkul/API/Http/Resources/Customer/Wishlist.php index 75b04de44..809f75da3 100644 --- a/packages/Webkul/API/Http/Resources/Customer/Wishlist.php +++ b/packages/Webkul/API/Http/Resources/Customer/Wishlist.php @@ -16,8 +16,8 @@ class Wishlist extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'product' => new ProductResource($this->product), + 'id' => $this->id, + 'product' => new ProductResource($this->product), 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, ]; diff --git a/packages/Webkul/API/Http/Resources/Inventory/InventorySource.php b/packages/Webkul/API/Http/Resources/Inventory/InventorySource.php index fab464195..dcb8a4b23 100644 --- a/packages/Webkul/API/Http/Resources/Inventory/InventorySource.php +++ b/packages/Webkul/API/Http/Resources/Inventory/InventorySource.php @@ -15,25 +15,25 @@ class InventorySource extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'code' => $this->code, - 'name' => $this->name, - 'description' => $this->description, - 'contact_name' => $this->contact_name, - 'contact_email' => $this->contact_email, + 'id' => $this->id, + 'code' => $this->code, + 'name' => $this->name, + 'description' => $this->description, + 'contact_name' => $this->contact_name, + 'contact_email' => $this->contact_email, 'contact_number' => $this->contact_number, - 'contact_fax' => $this->contact_fax, - 'country' => $this->country, - 'state' => $this->state, - 'city' => $this->city, - 'street' => $this->street, - 'postcode' => $this->postcode, - 'priority' => $this->priority, - 'latitude' => $this->latitude, - 'longitude' => $this->collongitudeongitudeuntry, - 'status' => $this->status, - 'created_at' => $this->created_at, - 'updated_at' => $this->updated_at, + 'contact_fax' => $this->contact_fax, + 'country' => $this->country, + 'state' => $this->state, + 'city' => $this->city, + 'street' => $this->street, + 'postcode' => $this->postcode, + 'priority' => $this->priority, + 'latitude' => $this->latitude, + 'longitude' => $this->collongitudeongitudeuntry, + 'status' => $this->status, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Sales/Invoice.php b/packages/Webkul/API/Http/Resources/Sales/Invoice.php index 239056f25..8c5a8dcc2 100644 --- a/packages/Webkul/API/Http/Resources/Sales/Invoice.php +++ b/packages/Webkul/API/Http/Resources/Sales/Invoice.php @@ -15,37 +15,37 @@ class Invoice extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'state' => $this->state, - 'email_sent' => $this->email_sent, - 'total_qty' => $this->total_qty, - 'base_currency_code' => $this->base_currency_code, - '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, + 'id' => $this->id, + 'state' => $this->state, + 'email_sent' => $this->email_sent, + 'total_qty' => $this->total_qty, + 'base_currency_code' => $this->base_currency_code, + '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, + '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 + 'order_address' => new OrderAddress($this->address), + 'transaction_id' => $this->transaction_id, + 'items' => InvoiceItem::collection($this->items), + 'created_at' => $this->created_at ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Sales/InvoiceItem.php b/packages/Webkul/API/Http/Resources/Sales/InvoiceItem.php index c5fd3d09b..bfdd0d7d3 100644 --- a/packages/Webkul/API/Http/Resources/Sales/InvoiceItem.php +++ b/packages/Webkul/API/Http/Resources/Sales/InvoiceItem.php @@ -15,34 +15,34 @@ class InvoiceItem extends JsonResource public function toArray($request) { 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, + '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), - 'child' => new self($this->child), - 'children' => Self::collection($this->children) + 'additional' => is_array($this->resource->additional) + ? $this->resource->additional + : json_decode($this->resource->additional, true), + 'child' => new self($this->child), + 'children' => Self::collection($this->children) ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Sales/Order.php b/packages/Webkul/API/Http/Resources/Sales/Order.php index 5f59e561c..325fc5873 100644 --- a/packages/Webkul/API/Http/Resources/Sales/Order.php +++ b/packages/Webkul/API/Http/Resources/Sales/Order.php @@ -17,93 +17,93 @@ class Order extends JsonResource public function toArray($request) { 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, - 'customer_first_name' => $this->customer_first_name, - '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, - 'total_item_count' => $this->total_item_count, - 'total_qty_ordered' => $this->total_qty_ordered, - 'base_currency_code' => $this->base_currency_code, - '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, + '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, + 'customer_first_name' => $this->customer_first_name, + '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, + 'total_item_count' => $this->total_item_count, + 'total_qty_ordered' => $this->total_qty_ordered, + 'base_currency_code' => $this->base_currency_code, + '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, + '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), - 'shipments' => Shipment::collection($this->shipments), - 'created_at' => $this->created_at + '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), + 'shipments' => Shipment::collection($this->shipments), + 'created_at' => $this->created_at ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Sales/OrderAddress.php b/packages/Webkul/API/Http/Resources/Sales/OrderAddress.php index bb18a5a6a..78e3db345 100644 --- a/packages/Webkul/API/Http/Resources/Sales/OrderAddress.php +++ b/packages/Webkul/API/Http/Resources/Sales/OrderAddress.php @@ -15,19 +15,19 @@ class OrderAddress extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'email' => $this->email, - 'first_name' => $this->first_name, - 'last_name' => $this->last_name, - 'address1' => explode(PHP_EOL, $this->address1), - 'country' => $this->country, + 'id' => $this->id, + 'email' => $this->email, + 'first_name' => $this->first_name, + 'last_name' => $this->last_name, + 'address1' => explode(PHP_EOL, $this->address1), + 'country' => $this->country, 'country_name' => core()->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, + 'state' => $this->state, + 'city' => $this->city, + 'postcode' => $this->postcode, + 'phone' => $this->phone, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Sales/OrderItem.php b/packages/Webkul/API/Http/Resources/Sales/OrderItem.php index a6420b480..f7eb3b8cb 100644 --- a/packages/Webkul/API/Http/Resources/Sales/OrderItem.php +++ b/packages/Webkul/API/Http/Resources/Sales/OrderItem.php @@ -16,70 +16,70 @@ class OrderItem extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - '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, + 'id' => $this->id, + '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, + '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), - 'child' => new self($this->child), - 'children' => Self::collection($this->children) + '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), + 'child' => new self($this->child), + 'children' => Self::collection($this->children) ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Sales/Shipment.php b/packages/Webkul/API/Http/Resources/Sales/Shipment.php index 6e9df69b1..74aade44a 100644 --- a/packages/Webkul/API/Http/Resources/Sales/Shipment.php +++ b/packages/Webkul/API/Http/Resources/Sales/Shipment.php @@ -17,17 +17,17 @@ class Shipment extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'status' => $this->status, - 'total_qty' => $this->total_qty, - 'total_weight' => $this->total_weight, - 'carrier_code' => $this->carrier_code, - 'carrier_title' => $this->carrier_title, - 'track_number' => $this->track_number, - 'email_sent' => $this->email_sent, - 'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)), + 'id' => $this->id, + 'status' => $this->status, + 'total_qty' => $this->total_qty, + 'total_weight' => $this->total_weight, + 'carrier_code' => $this->carrier_code, + 'carrier_title' => $this->carrier_title, + 'track_number' => $this->track_number, + 'email_sent' => $this->email_sent, + 'customer' => $this->when($this->customer_id, new CustomerResource($this->customer)), 'inventory_source' => $this->when($this->inventory_source_id, new InventorySourceResource($this->inventory_source)), - 'items' => ShipmentItem::collection($this->items), + 'items' => ShipmentItem::collection($this->items), ]; } } \ No newline at end of file diff --git a/packages/Webkul/API/Http/Resources/Sales/ShipmentItem.php b/packages/Webkul/API/Http/Resources/Sales/ShipmentItem.php index 678af6d6f..da57b0358 100644 --- a/packages/Webkul/API/Http/Resources/Sales/ShipmentItem.php +++ b/packages/Webkul/API/Http/Resources/Sales/ShipmentItem.php @@ -15,23 +15,23 @@ class ShipmentItem extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, - 'name' => $this->name, - 'description' => $this->description, - 'sku' => $this->sku, - '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, + 'id' => $this->id, + 'name' => $this->name, + 'description' => $this->description, + 'sku' => $this->sku, + '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, + '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) + 'additional' => is_array($this->resource->additional) + ? $this->resource->additional + : json_decode($this->resource->additional, true) ]; } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Config/acl.php b/packages/Webkul/Admin/src/Config/acl.php index 8b28872db..da1c7d9dd 100755 --- a/packages/Webkul/Admin/src/Config/acl.php +++ b/packages/Webkul/Admin/src/Config/acl.php @@ -2,420 +2,420 @@ return [ [ - 'key' => 'dashboard', - 'name' => 'admin::app.acl.dashboard', + 'key' => 'dashboard', + 'name' => 'admin::app.acl.dashboard', 'route' => 'admin.dashboard.index', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'sales', - 'name' => 'admin::app.acl.sales', + 'key' => 'sales', + 'name' => 'admin::app.acl.sales', 'route' => 'admin.sales.orders.index', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'sales.orders', - 'name' => 'admin::app.acl.orders', + 'key' => 'sales.orders', + 'name' => 'admin::app.acl.orders', 'route' => 'admin.sales.orders.index', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'sales.invoices', - 'name' => 'admin::app.acl.invoices', + 'key' => 'sales.invoices', + 'name' => 'admin::app.acl.invoices', 'route' => 'admin.sales.invoices.index', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'sales.shipments', - 'name' => 'admin::app.acl.shipments', + 'key' => 'sales.shipments', + 'name' => 'admin::app.acl.shipments', 'route' => 'admin.sales.shipments.index', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'catalog', - 'name' => 'admin::app.acl.catalog', + 'key' => 'catalog', + 'name' => 'admin::app.acl.catalog', 'route' => 'admin.catalog.index', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'catalog.products', - 'name' => 'admin::app.acl.products', + 'key' => 'catalog.products', + 'name' => 'admin::app.acl.products', 'route' => 'admin.catalog.products.index', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'catalog.products.create', - 'name' => 'admin::app.acl.create', + 'key' => 'catalog.products.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.catalog.products.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'catalog.products.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'catalog.products.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.catalog.products.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'catalog.products.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'catalog.products.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.catalog.products.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'catalog.categories', - 'name' => 'admin::app.acl.categories', + 'key' => 'catalog.categories', + 'name' => 'admin::app.acl.categories', 'route' => 'admin.catalog.categories.index', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'catalog.categories.create', - 'name' => 'admin::app.acl.create', + 'key' => 'catalog.categories.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.catalog.categories.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'catalog.categories.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'catalog.categories.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.catalog.categories.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'catalog.categories.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'catalog.categories.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.catalog.categories.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'catalog.attributes', - 'name' => 'admin::app.acl.attributes', + 'key' => 'catalog.attributes', + 'name' => 'admin::app.acl.attributes', 'route' => 'admin.catalog.attributes.index', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'catalog.attributes.create', - 'name' => 'admin::app.acl.create', + 'key' => 'catalog.attributes.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.catalog.attributes.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'catalog.attributes.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'catalog.attributes.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.catalog.attributes.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'catalog.attributes.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'catalog.attributes.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.catalog.attributes.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'catalog.families', - 'name' => 'admin::app.acl.attribute-families', + 'key' => 'catalog.families', + 'name' => 'admin::app.acl.attribute-families', 'route' => 'admin.catalog.families.index', - 'sort' => 4 + 'sort' => 4, ], [ - 'key' => 'catalog.families.create', - 'name' => 'admin::app.acl.create', + 'key' => 'catalog.families.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.catalog.families.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'catalog.families.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'catalog.families.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.catalog.families.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'catalog.families.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'catalog.families.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.catalog.families.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'customers', - 'name' => 'admin::app.acl.customers', + 'key' => 'customers', + 'name' => 'admin::app.acl.customers', 'route' => 'admin.customer.index', - 'sort' => 4 + 'sort' => 4, ], [ - 'key' => 'customers.customers', - 'name' => 'admin::app.acl.customers', + 'key' => 'customers.customers', + 'name' => 'admin::app.acl.customers', 'route' => 'admin.customer.index', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'customers.customers.create', - 'name' => 'admin::app.acl.create', + 'key' => 'customers.customers.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.customer.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'customers.customers.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'customers.customers.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.customer.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'customers.customers.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'customers.customers.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.customer.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'customers.groups', - 'name' => 'admin::app.acl.groups', + 'key' => 'customers.groups', + 'name' => 'admin::app.acl.groups', 'route' => 'admin.groups.index', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'customers.groups.create', - 'name' => 'admin::app.acl.create', + 'key' => 'customers.groups.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.groups.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'customers.groups.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'customers.groups.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.groups.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'customers.groups.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'customers.groups.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.groups.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'customers.reviews', - 'name' => 'admin::app.acl.reviews', + 'key' => 'customers.reviews', + 'name' => 'admin::app.acl.reviews', 'route' => 'admin.customer.review.index', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'customers.reviews.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'customers.reviews.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.customer.review.edit', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'customers.reviews.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'customers.reviews.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.customer.review.delete', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'configuration', - 'name' => 'admin::app.acl.configure', + 'key' => 'configuration', + 'name' => 'admin::app.acl.configure', 'route' => 'admin.configuration.index', - 'sort' => 5 + 'sort' => 5, ], [ - 'key' => 'settings', - 'name' => 'admin::app.acl.settings', + 'key' => 'settings', + 'name' => 'admin::app.acl.settings', 'route' => 'admin.users.index', - 'sort' => 6 + 'sort' => 6, ], [ - 'key' => 'settings.locales', - 'name' => 'admin::app.acl.locales', + 'key' => 'settings.locales', + 'name' => 'admin::app.acl.locales', 'route' => 'admin.locales.index', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.locales.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.locales.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.locales.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.locales.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.locales.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.locales.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.locales.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.locales.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.locales.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.currencies', - 'name' => 'admin::app.acl.currencies', + 'key' => 'settings.currencies', + 'name' => 'admin::app.acl.currencies', 'route' => 'admin.currencies.index', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.currencies.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.currencies.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.currencies.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.currencies.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.currencies.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.currencies.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.currencies.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.currencies.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.currencies.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.exchange_rates', - 'name' => 'admin::app.acl.exchange-rates', + 'key' => 'settings.exchange_rates', + 'name' => 'admin::app.acl.exchange-rates', 'route' => 'admin.exchange_rates.index', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.exchange_rates.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.exchange_rates.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.exchange_rates.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.exchange_rates.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.exchange_rates.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.exchange_rates.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.exchange_rates.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.exchange_rates.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.exchange_rates.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.inventory_sources', - 'name' => 'admin::app.acl.inventory-sources', + 'key' => 'settings.inventory_sources', + 'name' => 'admin::app.acl.inventory-sources', 'route' => 'admin.inventory_sources.index', - 'sort' => 4 + 'sort' => 4, ], [ - 'key' => 'settings.inventory_sources.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.inventory_sources.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.inventory_sources.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.inventory_sources.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.inventory_sources.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.inventory_sources.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.inventory_sources.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.inventory_sources.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.inventory_sources.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.channels', - 'name' => 'admin::app.acl.channels', + 'key' => 'settings.channels', + 'name' => 'admin::app.acl.channels', 'route' => 'admin.channels.index', - 'sort' => 5 + 'sort' => 5, ], [ - 'key' => 'settings.channels.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.channels.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.channels.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.channels.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.channels.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.channels.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.channels.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.channels.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.channels.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.users', - 'name' => 'admin::app.acl.users', + 'key' => 'settings.users', + 'name' => 'admin::app.acl.users', 'route' => 'admin.users.index', - 'sort' => 6 + 'sort' => 6, ], [ - 'key' => 'settings.users.users', - 'name' => 'admin::app.acl.users', + 'key' => 'settings.users.users', + 'name' => 'admin::app.acl.users', 'route' => 'admin.users.index', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.users.users.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.users.users.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.users.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.users.users.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.users.users.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.users.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.users.users.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.users.users.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.users.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.users.roles', - 'name' => 'admin::app.acl.roles', + 'key' => 'settings.users.roles', + 'name' => 'admin::app.acl.roles', 'route' => 'admin.roles.index', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.users.roles.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.users.roles.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.roles.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.users.roles.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.users.roles.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.roles.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.users.roles.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.users.roles.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.roles.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.sliders', - 'name' => 'admin::app.acl.sliders', + 'key' => 'settings.sliders', + 'name' => 'admin::app.acl.sliders', 'route' => 'admin.sliders.index', - 'sort' => 7 + 'sort' => 7, ], [ - 'key' => 'settings.sliders.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.sliders.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.sliders.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.sliders.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.sliders.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.sliders.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.sliders.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.sliders.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.sliders.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.taxes', - 'name' => 'admin::app.acl.taxes', + 'key' => 'settings.taxes', + 'name' => 'admin::app.acl.taxes', 'route' => 'admin.tax-categories.index', - 'sort' => 8 + 'sort' => 8, ], [ - 'key' => 'settings.taxes.tax-categories', - 'name' => 'admin::app.acl.tax-categories', + 'key' => 'settings.taxes.tax-categories', + 'name' => 'admin::app.acl.tax-categories', 'route' => 'admin.tax-categories.index', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.taxes.tax-categories.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.taxes.tax-categories.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.tax-categories.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.taxes.tax-categories.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.taxes.tax-categories.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.tax-categories.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.taxes.tax-categories.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.taxes.tax-categories.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.tax-categories.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'settings.taxes.tax-rates', - 'name' => 'admin::app.acl.tax-rates', + 'key' => 'settings.taxes.tax-rates', + 'name' => 'admin::app.acl.tax-rates', 'route' => 'admin.tax-rates.index', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.taxes.tax-rates.create', - 'name' => 'admin::app.acl.create', + 'key' => 'settings.taxes.tax-rates.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.tax-rates.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'settings.taxes.tax-rates.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'settings.taxes.tax-rates.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.tax-rates.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'settings.taxes.tax-rates.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'settings.taxes.tax-rates.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.tax-rates.delete', - 'sort' => 3 + 'sort' => 3, ], [ - 'key' => 'promotions', - 'name' => 'admin::app.acl.promotions', + 'key' => 'promotions', + 'name' => 'admin::app.acl.promotions', 'route' => 'admin.cart-rules.index', - 'sort' => 7 + 'sort' => 7, ], [ - 'key' => 'promotions.cart-rules', - 'name' => 'admin::app.acl.cart-rules', + 'key' => 'promotions.cart-rules', + 'name' => 'admin::app.acl.cart-rules', 'route' => 'admin.cart-rules.index', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'promotions.cart-rules.create', - 'name' => 'admin::app.acl.create', + 'key' => 'promotions.cart-rules.create', + 'name' => 'admin::app.acl.create', 'route' => 'admin.cart-rules.create', - 'sort' => 1 + 'sort' => 1, ], [ - 'key' => 'promotions.cart-rules.edit', - 'name' => 'admin::app.acl.edit', + 'key' => 'promotions.cart-rules.edit', + 'name' => 'admin::app.acl.edit', 'route' => 'admin.cart-rules.edit', - 'sort' => 2 + 'sort' => 2, ], [ - 'key' => 'promotions.cart-rules.delete', - 'name' => 'admin::app.acl.delete', + 'key' => 'promotions.cart-rules.delete', + 'name' => 'admin::app.acl.delete', 'route' => 'admin.cart-rules.delete', - 'sort' => 3 + 'sort' => 3, ], ]; diff --git a/packages/Webkul/Admin/src/Config/menu.php b/packages/Webkul/Admin/src/Config/menu.php index ce1da1d85..426ef3edc 100755 --- a/packages/Webkul/Admin/src/Config/menu.php +++ b/packages/Webkul/Admin/src/Config/menu.php @@ -2,214 +2,214 @@ return [ [ - 'key' => 'dashboard', - 'name' => 'admin::app.layouts.dashboard', - 'route' => 'admin.dashboard.index', - 'sort' => 1, - 'icon-class' => 'dashboard-icon' + 'key' => 'dashboard', + 'name' => 'admin::app.layouts.dashboard', + 'route' => 'admin.dashboard.index', + 'sort' => 1, + 'icon-class' => 'dashboard-icon', ], [ - 'key' => 'sales', - 'name' => 'admin::app.layouts.sales', - 'route' => 'admin.sales.orders.index', - 'sort' => 2, - 'icon-class' => 'sales-icon' + 'key' => 'sales', + 'name' => 'admin::app.layouts.sales', + 'route' => 'admin.sales.orders.index', + 'sort' => 2, + 'icon-class' => 'sales-icon', ], [ - 'key' => 'sales.orders', - 'name' => 'admin::app.layouts.orders', - 'route' => 'admin.sales.orders.index', - 'sort' => 1, - 'icon-class' => '' + 'key' => 'sales.orders', + 'name' => 'admin::app.layouts.orders', + 'route' => 'admin.sales.orders.index', + 'sort' => 1, + 'icon-class' => '', ], [ - 'key' => 'sales.shipments', - 'name' => 'admin::app.layouts.shipments', - 'route' => 'admin.sales.shipments.index', - 'sort' => 2, - 'icon-class' => '' + 'key' => 'sales.shipments', + 'name' => 'admin::app.layouts.shipments', + 'route' => 'admin.sales.shipments.index', + 'sort' => 2, + 'icon-class' => '', ], [ - 'key' => 'sales.invoices', - 'name' => 'admin::app.layouts.invoices', - 'route' => 'admin.sales.invoices.index', - 'sort' => 3, - 'icon-class' => '' + 'key' => 'sales.invoices', + 'name' => 'admin::app.layouts.invoices', + 'route' => 'admin.sales.invoices.index', + 'sort' => 3, + 'icon-class' => '', ], [ - 'key' => 'sales.refunds', - 'name' => 'admin::app.layouts.refunds', - 'route' => 'admin.sales.refunds.index', - 'sort' => 4, - 'icon-class' => '' + 'key' => 'sales.refunds', + 'name' => 'admin::app.layouts.refunds', + 'route' => 'admin.sales.refunds.index', + 'sort' => 4, + 'icon-class' => '', ], [ - 'key' => 'catalog', - 'name' => 'admin::app.layouts.catalog', - 'route' => 'admin.catalog.products.index', - 'sort' => 3, - 'icon-class' => 'catalog-icon' + 'key' => 'catalog', + 'name' => 'admin::app.layouts.catalog', + 'route' => 'admin.catalog.products.index', + 'sort' => 3, + 'icon-class' => 'catalog-icon', ], [ - 'key' => 'catalog.products', - 'name' => 'admin::app.layouts.products', - 'route' => 'admin.catalog.products.index', - 'sort' => 1, - 'icon-class' => '' + 'key' => 'catalog.products', + 'name' => 'admin::app.layouts.products', + 'route' => 'admin.catalog.products.index', + 'sort' => 1, + 'icon-class' => '', ], [ - 'key' => 'catalog.categories', - 'name' => 'admin::app.layouts.categories', - 'route' => 'admin.catalog.categories.index', - 'sort' => 3, - 'icon-class' => '' + 'key' => 'catalog.categories', + 'name' => 'admin::app.layouts.categories', + 'route' => 'admin.catalog.categories.index', + 'sort' => 3, + 'icon-class' => '', ], [ - 'key' => 'catalog.attributes', - 'name' => 'admin::app.layouts.attributes', - 'route' => 'admin.catalog.attributes.index', - 'sort' => 2, - 'icon-class' => '' + 'key' => 'catalog.attributes', + 'name' => 'admin::app.layouts.attributes', + 'route' => 'admin.catalog.attributes.index', + 'sort' => 2, + 'icon-class' => '', ], [ - 'key' => 'catalog.families', - 'name' => 'admin::app.layouts.attribute-families', - 'route' => 'admin.catalog.families.index', - 'sort' => 4, - 'icon-class' => '' + 'key' => 'catalog.families', + 'name' => 'admin::app.layouts.attribute-families', + 'route' => 'admin.catalog.families.index', + 'sort' => 4, + 'icon-class' => '', ], [ - 'key' => 'customers', - 'name' => 'admin::app.layouts.customers', - 'route' => 'admin.customer.index', - 'sort' => 4, - 'icon-class' => 'customer-icon' + 'key' => 'customers', + 'name' => 'admin::app.layouts.customers', + 'route' => 'admin.customer.index', + 'sort' => 4, + 'icon-class' => 'customer-icon', ], [ - 'key' => 'customers.customers', - 'name' => 'admin::app.layouts.customers', - 'route' => 'admin.customer.index', - 'sort' => 1, - 'icon-class' => '' + 'key' => 'customers.customers', + 'name' => 'admin::app.layouts.customers', + 'route' => 'admin.customer.index', + 'sort' => 1, + 'icon-class' => '', ], [ - 'key' => 'customers.groups', - 'name' => 'admin::app.layouts.groups', - 'route' => 'admin.groups.index', - 'sort' => 2, - 'icon-class' => '' + 'key' => 'customers.groups', + 'name' => 'admin::app.layouts.groups', + 'route' => 'admin.groups.index', + 'sort' => 2, + 'icon-class' => '', ], [ - 'key' => 'customers.reviews', - 'name' => 'admin::app.layouts.reviews', - 'route' => 'admin.customer.review.index', - 'sort' => 3, - 'icon-class' => '' + 'key' => 'customers.reviews', + 'name' => 'admin::app.layouts.reviews', + 'route' => 'admin.customer.review.index', + 'sort' => 3, + 'icon-class' => '', ], [ - 'key' => 'customers.subscribers', - 'name' => 'admin::app.layouts.newsletter-subscriptions', - 'route' => 'admin.customers.subscribers.index', - 'sort' => 4, - 'icon-class' => '' + 'key' => 'customers.subscribers', + 'name' => 'admin::app.layouts.newsletter-subscriptions', + 'route' => 'admin.customers.subscribers.index', + 'sort' => 4, + 'icon-class' => '', ], [ - 'key' => 'configuration', - 'name' => 'admin::app.layouts.configure', - 'route' => 'admin.configuration.index', - 'sort' => 7, - 'icon-class' => 'configuration-icon' + 'key' => 'configuration', + 'name' => 'admin::app.layouts.configure', + 'route' => 'admin.configuration.index', + 'sort' => 7, + 'icon-class' => 'configuration-icon', ], [ - 'key' => 'settings', - 'name' => 'admin::app.layouts.settings', - 'route' => 'admin.locales.index', - 'sort' => 6, - 'icon-class' => 'settings-icon' + 'key' => 'settings', + 'name' => 'admin::app.layouts.settings', + 'route' => 'admin.locales.index', + 'sort' => 6, + 'icon-class' => 'settings-icon', ], [ - 'key' => 'settings.locales', - 'name' => 'admin::app.layouts.locales', - 'route' => 'admin.locales.index', - 'sort' => 1, - 'icon-class' => '' + 'key' => 'settings.locales', + 'name' => 'admin::app.layouts.locales', + 'route' => 'admin.locales.index', + 'sort' => 1, + 'icon-class' => '', ], [ - 'key' => 'settings.currencies', - 'name' => 'admin::app.layouts.currencies', - 'route' => 'admin.currencies.index', - 'sort' => 2, - 'icon-class' => '' + 'key' => 'settings.currencies', + 'name' => 'admin::app.layouts.currencies', + 'route' => 'admin.currencies.index', + 'sort' => 2, + 'icon-class' => '', ], [ - 'key' => 'settings.exchange_rates', - 'name' => 'admin::app.layouts.exchange-rates', - 'route' => 'admin.exchange_rates.index', - 'sort' => 3, - 'icon-class' => '' + 'key' => 'settings.exchange_rates', + 'name' => 'admin::app.layouts.exchange-rates', + 'route' => 'admin.exchange_rates.index', + 'sort' => 3, + 'icon-class' => '', ], [ - 'key' => 'settings.inventory_sources', - 'name' => 'admin::app.layouts.inventory-sources', - 'route' => 'admin.inventory_sources.index', - 'sort' => 4, - 'icon-class' => '' + 'key' => 'settings.inventory_sources', + 'name' => 'admin::app.layouts.inventory-sources', + 'route' => 'admin.inventory_sources.index', + 'sort' => 4, + 'icon-class' => '', ], [ - 'key' => 'settings.channels', - 'name' => 'admin::app.layouts.channels', - 'route' => 'admin.channels.index', - 'sort' => 5, - 'icon-class' => '' + 'key' => 'settings.channels', + 'name' => 'admin::app.layouts.channels', + 'route' => 'admin.channels.index', + 'sort' => 5, + 'icon-class' => '', ], [ - 'key' => 'settings.users', - 'name' => 'admin::app.layouts.users', - 'route' => 'admin.users.index', - 'sort' => 6, - 'icon-class' => '' + 'key' => 'settings.users', + 'name' => 'admin::app.layouts.users', + 'route' => 'admin.users.index', + 'sort' => 6, + 'icon-class' => '', ], [ - 'key' => 'settings.users.users', - 'name' => 'admin::app.layouts.users', - 'route' => 'admin.users.index', - 'sort' => 1, - 'icon-class' => '' + 'key' => 'settings.users.users', + 'name' => 'admin::app.layouts.users', + 'route' => 'admin.users.index', + 'sort' => 1, + 'icon-class' => '', ], [ - 'key' => 'settings.users.roles', - 'name' => 'admin::app.layouts.roles', - 'route' => 'admin.roles.index', - 'sort' => 2, - 'icon-class' => '' + 'key' => 'settings.users.roles', + 'name' => 'admin::app.layouts.roles', + 'route' => 'admin.roles.index', + 'sort' => 2, + 'icon-class' => '', ], [ - 'key' => 'settings.sliders', - 'name' => 'admin::app.layouts.sliders', - 'route' => 'admin.sliders.index', - 'sort' => 7, - 'icon-class' => '' + 'key' => 'settings.sliders', + 'name' => 'admin::app.layouts.sliders', + 'route' => 'admin.sliders.index', + 'sort' => 7, + 'icon-class' => '', ], [ - 'key' => 'settings.taxes', - 'name' => 'admin::app.layouts.taxes', - 'route' => 'admin.tax-categories.index', - 'sort' => 8, - 'icon-class' => '' + 'key' => 'settings.taxes', + 'name' => 'admin::app.layouts.taxes', + 'route' => 'admin.tax-categories.index', + 'sort' => 8, + 'icon-class' => '', ], [ - 'key' => 'settings.taxes.tax-categories', - 'name' => 'admin::app.layouts.tax-categories', - 'route' => 'admin.tax-categories.index', - 'sort' => 1, - 'icon-class' => '' + 'key' => 'settings.taxes.tax-categories', + 'name' => 'admin::app.layouts.tax-categories', + 'route' => 'admin.tax-categories.index', + 'sort' => 1, + 'icon-class' => '', ], [ - 'key' => 'settings.taxes.tax-rates', - 'name' => 'admin::app.layouts.tax-rates', - 'route' => 'admin.tax-rates.index', - 'sort' => 2, - 'icon-class' => '' + 'key' => 'settings.taxes.tax-rates', + 'name' => 'admin::app.layouts.tax-rates', + 'route' => 'admin.tax-rates.index', + 'sort' => 2, + 'icon-class' => '', ], [ - 'key' => 'promotions', - 'name' => 'admin::app.layouts.promotions', - 'route' => 'admin.catalog-rules.index', - 'sort' => 5, - 'icon-class' => 'promotion-icon' + 'key' => 'promotions', + 'name' => 'admin::app.layouts.promotions', + 'route' => 'admin.catalog-rules.index', + 'sort' => 5, + 'icon-class' => 'promotion-icon', ], [ - 'key' => 'promotions.catalog-rules', - 'name' => 'admin::app.promotions.catalog-rules.title', - 'route' => 'admin.catalog-rules.index', - 'sort' => 1, - 'icon-class' => '' + 'key' => 'promotions.catalog-rules', + 'name' => 'admin::app.promotions.catalog-rules.title', + 'route' => 'admin.catalog-rules.index', + 'sort' => 1, + 'icon-class' => '', ], [ - 'key' => 'promotions.cart-rules', - 'name' => 'admin::app.promotions.cart-rules.title', - 'route' => 'admin.cart-rules.index', - 'sort' => 2, - 'icon-class' => '' + 'key' => 'promotions.cart-rules', + 'name' => 'admin::app.promotions.cart-rules.title', + 'route' => 'admin.cart-rules.index', + 'sort' => 2, + 'icon-class' => '', ], [ - 'key' => 'cms', - 'name' => 'admin::app.layouts.cms', - 'route' => 'admin.cms.index', - 'sort' => 5, - 'icon-class' => 'cms-icon' + 'key' => 'cms', + 'name' => 'admin::app.layouts.cms', + 'route' => 'admin.cms.index', + 'sort' => 5, + 'icon-class' => 'cms-icon', ], [ - 'key' => 'cms.pages', - 'name' => 'admin::app.cms.pages.pages', - 'route' => 'admin.cms.index', - 'sort' => 1, - 'icon-class' => '' + 'key' => 'cms.pages', + 'name' => 'admin::app.cms.pages.pages', + 'route' => 'admin.cms.index', + 'sort' => 1, + 'icon-class' => '', ] ]; \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Config/system.php b/packages/Webkul/Admin/src/Config/system.php index 6daa45a16..5e053eac5 100644 --- a/packages/Webkul/Admin/src/Config/system.php +++ b/packages/Webkul/Admin/src/Config/system.php @@ -48,16 +48,7 @@ return [ ], [ 'name' => 'footer_toggle', 'title' => 'admin::app.admin.system.footer-toggle', - 'type' => 'select', - 'options' => [ - [ - 'title' => 'True', - 'value' => 1, - ], [ - 'title' => 'False', - 'value' => 0, - ], - ], + 'type' => 'boolean', 'locale_based' => true, 'channel_based' => true, ], diff --git a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php index f397ee46e..e70fd6e2d 100644 --- a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php @@ -2,66 +2,58 @@ namespace Webkul\Admin\DataGrids; -use DB; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use Webkul\Customer\Repositories\CustomerRepository as Customer; +use Webkul\Customer\Repositories\CustomerRepository; -/** - * Address Data Grid class - * - * @author Vivek Sharma - * @copyright 2019 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AddressDataGrid extends DataGrid { /** - * - * @var integer + * @var string */ public $index = 'address_id'; - protected $sortOrder = 'desc'; //asc or desc + /** + * @var string + */ + protected $sortOrder = 'desc'; /** * CustomerRepository object * * @var object - */ - protected $customer; + */ + protected $customerRepository; /** - * Create a new controller instance. + * Create a new datagrid instance. * - * @param Webkul\Customer\Repositories\CustomerRepository $customer + * @param Webkul\Customer\Repositories\CustomerRepository $customerRepository * @return void */ - public function __construct( - Customer $customer - ) + public function __construct(CustomerRepository $customerRepository) { - parent::__construct(); + $this->customerRepository = $customerRepository; - $this->customer = $customer; + parent::__construct(); } public function prepareQueryBuilder() { - - $customer = $this->customer->find(request('id')); + $customer = $this->customerRepository->find(request('id')); $queryBuilder = DB::table('customer_addresses as ca') - ->leftJoin('countries', 'ca.country', '=', 'countries.code') - ->leftJoin('customers as c', 'ca.customer_id', '=', 'c.id') - ->addSelect('ca.id as address_id', 'ca.company_name', 'ca.address1', 'ca.country', DB::raw('' . DB::getTablePrefix() . 'countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') - ->where('c.id', $customer->id); + ->leftJoin('countries', 'ca.country', '=', 'countries.code') + ->leftJoin('customers as c', 'ca.customer_id', '=', 'c.id') + ->addSelect('ca.id as address_id', 'ca.company_name', 'ca.address1', 'ca.country', DB::raw('' . DB::getTablePrefix() . 'countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') + ->where('c.id', $customer->id); $queryBuilder = $queryBuilder->leftJoin('country_states', function($qb) { $qb->on('ca.state', 'country_states.code') - ->on('countries.id', 'country_states.country_id'); + ->on('countries.id', 'country_states.country_id'); }); - $queryBuilder - ->groupBy('ca.id') + $queryBuilder->groupBy('ca.id') ->addSelect(DB::raw(DB::getTablePrefix() . 'country_states.default_name as state_name')); $this->addFilter('address_id', 'ca.id'); @@ -78,102 +70,102 @@ class AddressDataGrid extends DataGrid public function addColumns() { - $this->addColumn([ - 'index' => 'address_id', - 'label' => trans('admin::app.customers.addresses.address-id'), - 'type' => 'number', + 'index' => 'address_id', + 'label' => trans('admin::app.customers.addresses.address-id'), + 'type' => 'number', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'address1', - 'label' => trans('admin::app.customers.addresses.address-1'), - 'type' => 'string', + 'index' => 'address1', + 'label' => trans('admin::app.customers.addresses.address-1'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'city', - 'label' => trans('admin::app.customers.addresses.city'), - 'type' => 'string', + 'index' => 'city', + 'label' => trans('admin::app.customers.addresses.city'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'state_name', - 'label' => trans('admin::app.customers.addresses.state-name'), - 'type' => 'string', + 'index' => 'state_name', + 'label' => trans('admin::app.customers.addresses.state-name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'country_name', - 'label' => trans('admin::app.customers.addresses.country-name'), - 'type' => 'string', + 'index' => 'country_name', + 'label' => trans('admin::app.customers.addresses.country-name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'postcode', - 'label' => trans('admin::app.customers.addresses.postcode'), - 'type' => 'string', + 'index' => 'postcode', + 'label' => trans('admin::app.customers.addresses.postcode'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'default_address', - 'label' => trans('admin::app.customers.addresses.default-address'), - 'type' => 'boolean', - 'sortable' => true, + 'index' => 'default_address', + 'label' => trans('admin::app.customers.addresses.default-address'), + 'type' => 'boolean', + 'sortable' => true, 'searchable' => false, - 'closure' => true, - 'wrapper' => function($row) { - if ($row->default_address == 1) + 'closure' => true, + 'wrapper' => function($row) { + if ($row->default_address == 1) { return '' . trans('admin::app.customers.addresses.yes') . ''; - else + } else { return trans('admin::app.customers.addresses.dash'); - } + } + }, ]); } public function prepareActions() { $this->addAction([ - 'type' => 'Edit', - 'method' => 'GET', //use post only for redirects only - 'route' => 'admin.customer.addresses.edit', - 'icon' => 'icon pencil-lg-icon' + 'type' => 'Edit', + 'method' => 'GET', + 'route' => 'admin.customer.addresses.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'type' => 'Delete', - 'method' => 'POST', - 'route' => 'admin.customer.addresses.delete', + 'type' => 'Delete', + 'method' => 'POST', + 'route' => 'admin.customer.addresses.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'address']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon', ]); } public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', - 'label' => trans('admin::app.customers.addresses.delete'), + 'type' => 'delete', + 'label' => trans('admin::app.customers.addresses.delete'), 'action' => route('admin.customer.addresses.massdelete', request('id')), - 'method' => 'DELETE' + 'method' => 'DELETE', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php index 05ff46cc3..3af4bc95f 100755 --- a/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeDataGrid.php @@ -2,26 +2,20 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * AttributeDataGrid class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AttributeDataGrid extends DataGrid { - protected $index = 'id'; // column that needs to be treated as index column + protected $index = 'id'; - protected $sortOrder = 'desc'; // asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { $queryBuilder = DB::table('attributes') - ->select('id') - ->addSelect('id', 'code', 'admin_name', 'type', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel'); + ->select('id') + ->addSelect('id', 'code', 'admin_name', 'type', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel'); $this->setQueryBuilder($queryBuilder); } @@ -29,126 +23,130 @@ class AttributeDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.code'), - 'type' => 'string', + 'index' => 'code', + 'label' => trans('admin::app.datagrid.code'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'admin_name', - 'label' => trans('admin::app.name'), - 'type' => 'string', + 'index' => 'admin_name', + 'label' => trans('admin::app.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'type', - 'label' => trans('admin::app.type'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'type', + 'label' => trans('admin::app.type'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'is_required', - 'label' => trans('admin::app.required'), - 'type' => 'boolean', - 'sortable' => true, + 'index' => 'is_required', + 'label' => trans('admin::app.required'), + 'type' => 'boolean', + 'sortable' => true, 'searchable' => false, - 'wrapper' => function($value) { - if ($value->is_required == 1) + 'wrapper' => function($value) { + if ($value->is_required == 1) { return 'True'; - else + } else { return 'False'; - } + } + }, ]); $this->addColumn([ - 'index' => 'is_unique', - 'label' => trans('admin::app.unique'), - 'type' => 'boolean', - 'sortable' => true, + 'index' => 'is_unique', + 'label' => trans('admin::app.unique'), + 'type' => 'boolean', + 'sortable' => true, 'searchable' => false, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->is_unique == 1) + 'wrapper' => function($value) { + if ($value->is_unique == 1) { return 'True'; - else + } else { return 'False'; - } + } + }, ]); $this->addColumn([ - 'index' => 'value_per_locale', - 'label' => trans('admin::app.locale-based'), - 'type' => 'boolean', - 'sortable' => true, + 'index' => 'value_per_locale', + 'label' => trans('admin::app.locale-based'), + 'type' => 'boolean', + 'sortable' => true, 'searchable' => false, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->value_per_locale == 1) + 'wrapper' => function($value) { + if ($value->value_per_locale == 1) { return 'True'; - else + } else { return 'False'; - } + } + }, ]); $this->addColumn([ - 'index' => 'value_per_channel', - 'label' => trans('admin::app.channel-based'), - 'type' => 'boolean', - 'sortable' => true, + 'index' => 'value_per_channel', + 'label' => trans('admin::app.channel-based'), + 'type' => 'boolean', + 'sortable' => true, 'searchable' => false, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->value_per_channel == 1) + 'wrapper' => function($value) { + if ($value->value_per_channel == 1) { return 'True'; - else + } else { return 'False'; - } + } + }, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Attribute', - 'method' => 'GET', //use get for redirects only - 'route' => 'admin.catalog.attributes.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Attribute', + 'method' => 'GET', + 'route' => 'admin.catalog.attributes.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Attribute', - 'method' => 'POST', // other than get request it fires ajax and self refreshes datagrid - 'route' => 'admin.catalog.attributes.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete Attribute', + 'method' => 'POST', + 'route' => 'admin.catalog.attributes.delete', + 'icon' => 'icon trash-icon', ]); } public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', + 'type' => 'delete', 'action' => route('admin.catalog.attributes.massdelete'), - 'label' => trans('admin::app.datagrid.delete'), - 'index' => 'admin_name', - 'method' => 'DELETE' + 'label' => trans('admin::app.datagrid.delete'), + 'index' => 'admin_name', + 'method' => 'DELETE', ]); } } diff --git a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php index b0d4141cb..5169e3fd5 100755 --- a/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AttributeFamilyDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * AttributeFamilyDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AttributeFamilyDataGrid extends DataGrid { - protected $index = 'id'; //the column that needs to be treated as index column + protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,47 +21,46 @@ class AttributeFamilyDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'code', + 'label' => trans('admin::app.code'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, 'filterable' => true ]); $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.code'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.name'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Attribute Family', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.catalog.families.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Attribute Family', + 'method' => 'GET', + 'route' => 'admin.catalog.families.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Attribute Family', - 'method' => 'POST', // use GET request only for redirect purposes and POST for rest - 'route' => 'admin.catalog.families.delete', - // 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), - 'icon' => 'icon trash-icon' + 'title' => 'Delete Attribute Family', + 'method' => 'POST', + 'route' => 'admin.catalog.families.delete', + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php index e2f6f61f1..a1b72098e 100644 --- a/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php @@ -2,15 +2,9 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * CMSPagesDataGrid class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CMSPageDataGrid extends DataGrid { protected $index = 'id'; @@ -20,11 +14,11 @@ class CMSPageDataGrid extends DataGrid public function prepareQueryBuilder() { $queryBuilder = DB::table('cms_pages') - ->select('cms_pages.id', 'cms_page_translations.page_title', 'cms_page_translations.url_key') - ->leftJoin('cms_page_translations', function($leftJoin) { - $leftJoin->on('cms_pages.id', '=', 'cms_page_translations.cms_page_id') - ->where('cms_page_translations.locale', app()->getLocale()); - }); + ->select('cms_pages.id', 'cms_page_translations.page_title', 'cms_page_translations.url_key') + ->leftJoin('cms_page_translations', function($leftJoin) { + $leftJoin->on('cms_pages.id', '=', 'cms_page_translations.cms_page_id') + ->where('cms_page_translations.locale', app()->getLocale()); + }); $this->addFilter('id', 'cms_pages.id'); @@ -34,56 +28,56 @@ class CMSPageDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'page_title', - 'label' => trans('admin::app.cms.pages.page-title'), - 'type' => 'string', + 'index' => 'page_title', + 'label' => trans('admin::app.cms.pages.page-title'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'url_key', - 'label' => trans('admin::app.datagrid.url-key'), - 'type' => 'string', + 'index' => 'url_key', + 'label' => trans('admin::app.datagrid.url-key'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit CMSPage', + 'title' => 'Edit CMSPage', 'method' => 'GET', - 'route' => 'admin.cms.edit', - 'icon' => 'icon pencil-lg-icon' + 'route' => 'admin.cms.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete CMSPage', + 'title' => 'Delete CMSPage', 'method' => 'POST', - 'route' => 'admin.cms.delete', - 'icon' => 'icon trash-icon' + 'route' => 'admin.cms.delete', + 'icon' => 'icon trash-icon', ]); } public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', - 'label' => trans('admin::app.datagrid.delete'), + 'type' => 'delete', + 'label' => trans('admin::app.datagrid.delete'), 'action' => route('admin.cms.mass-delete'), - 'method' => 'DELETE' + 'method' => 'DELETE', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CartRuleCouponDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CartRuleCouponDataGrid.php index f4eeac150..965e7138f 100644 --- a/packages/Webkul/Admin/src/DataGrids/CartRuleCouponDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CartRuleCouponDataGrid.php @@ -2,15 +2,9 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * CartRuleCouponDataGrid class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CartRuleCouponDataGrid extends DataGrid { protected $index = 'id'; @@ -20,8 +14,8 @@ class CartRuleCouponDataGrid extends DataGrid public function prepareQueryBuilder() { $queryBuilder = DB::table('cart_rule_coupons') - ->addSelect('id', 'code', 'created_at', 'expired_at', 'times_used') - ->where('cart_rule_coupons.cart_rule_id', collect(request()->segments())->last()); + ->addSelect('id', 'code', 'created_at', 'expired_at', 'times_used') + ->where('cart_rule_coupons.cart_rule_id', collect(request()->segments())->last()); $this->setQueryBuilder($queryBuilder); } @@ -29,58 +23,58 @@ class CartRuleCouponDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.coupon-code'), - 'type' => 'string', + 'index' => 'code', + 'label' => trans('admin::app.datagrid.coupon-code'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'created_at', - 'label' => trans('admin::app.datagrid.created-date'), - 'type' => 'datetime', - 'sortable' => true, + 'index' => 'created_at', + 'label' => trans('admin::app.datagrid.created-date'), + 'type' => 'datetime', + 'sortable' => true, 'searchable' => false, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'expired_at', - 'label' => trans('admin::app.datagrid.expiration-date'), - 'type' => 'datetime', - 'sortable' => true, + 'index' => 'expired_at', + 'label' => trans('admin::app.datagrid.expiration-date'), + 'type' => 'datetime', + 'sortable' => true, 'searchable' => false, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'times_used', - 'label' => trans('admin::app.datagrid.times-used'), - 'type' => 'number', + 'index' => 'times_used', + 'label' => trans('admin::app.datagrid.times-used'), + 'type' => 'number', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', + 'type' => 'delete', 'action' => route('admin.cart-rule-coupons.mass-delete'), - 'label' => trans('admin::app.datagrid.delete'), - 'method' => 'DELETE' + 'label' => trans('admin::app.datagrid.delete'), + 'method' => 'DELETE', ]); } } diff --git a/packages/Webkul/Admin/src/DataGrids/CartRuleDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CartRuleDataGrid.php index c6efb9517..f97b43e10 100644 --- a/packages/Webkul/Admin/src/DataGrids/CartRuleDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CartRuleDataGrid.php @@ -2,15 +2,9 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * Cart Rule DataGrid class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CartRuleDataGrid extends DataGrid { protected $index = 'id'; @@ -20,14 +14,13 @@ class CartRuleDataGrid extends DataGrid public function prepareQueryBuilder() { $queryBuilder = DB::table('cart_rules') - ->leftJoin('cart_rule_coupons', function($leftJoin) { - $leftJoin->on('cart_rule_coupons.cart_rule_id', '=', 'cart_rules.id') - ->where('cart_rule_coupons.is_primary', 1); - }) - ->addSelect('cart_rules.id', 'name', 'cart_rule_coupons.code as coupon_code', 'status', 'starts_from', 'ends_till', 'sort_order'); + ->leftJoin('cart_rule_coupons', function($leftJoin) { + $leftJoin->on('cart_rule_coupons.cart_rule_id', '=', 'cart_rules.id') + ->where('cart_rule_coupons.is_primary', 1); + }) + ->addSelect('cart_rules.id', 'name', 'cart_rule_coupons.code as coupon_code', 'status', 'starts_from', 'ends_till', 'sort_order'); $this->addFilter('id', 'cart_rules.id'); - $this->addFilter('coupon_code', 'cart_rule_coupons.code'); $this->setQueryBuilder($queryBuilder); @@ -36,89 +29,90 @@ class CartRuleDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'coupon_code', - 'label' => trans('admin::app.datagrid.coupon-code'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'starts_from', - 'label' => trans('admin::app.datagrid.start'), - 'type' => 'datetime', - 'sortable' => true, - 'searchable' => false, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'ends_till', - 'label' => trans('admin::app.datagrid.end'), - 'type' => 'datetime', - 'sortable' => true, - 'searchable' => false, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'status', - 'label' => trans('admin::app.status'), - 'type' => 'boolean', - 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->status == 1) - return trans('admin::app.datagrid.active'); - else - return trans('admin::app.datagrid.inactive'); - } ]); $this->addColumn([ - 'index' => 'sort_order', - 'label' => trans('admin::app.datagrid.priority'), - 'type' => 'number', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'coupon_code', + 'label' => trans('admin::app.datagrid.coupon-code'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'starts_from', + 'label' => trans('admin::app.datagrid.start'), + 'type' => 'datetime', + 'sortable' => true, + 'searchable' => false, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'ends_till', + 'label' => trans('admin::app.datagrid.end'), + 'type' => 'datetime', + 'sortable' => true, + 'searchable' => false, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'status', + 'label' => trans('admin::app.status'), + 'type' => 'boolean', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + 'wrapper' => function($value) { + if ($value->status == 1) { + return trans('admin::app.datagrid.active'); + } else { + return trans('admin::app.datagrid.inactive'); + } + }, + ]); + + $this->addColumn([ + 'index' => 'sort_order', + 'label' => trans('admin::app.datagrid.priority'), + 'type' => 'number', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Cart Rule', + 'title' => 'Edit Cart Rule', 'method' => 'GET', - 'route' => 'admin.cart-rules.edit', - 'icon' => 'icon pencil-lg-icon' + 'route' => 'admin.cart-rules.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Cart Rule', + 'title' => 'Delete Cart Rule', 'method' => 'POST', - 'route' => 'admin.cart-rules.delete', - 'icon' => 'icon trash-icon' + 'route' => 'admin.cart-rules.delete', + 'icon' => 'icon trash-icon', ]); } } diff --git a/packages/Webkul/Admin/src/DataGrids/CatalogRuleDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CatalogRuleDataGrid.php index e57e977a1..7d8f24719 100644 --- a/packages/Webkul/Admin/src/DataGrids/CatalogRuleDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CatalogRuleDataGrid.php @@ -2,15 +2,9 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * Catalog Rule DataGrid class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CatalogRuleDataGrid extends DataGrid { protected $index = 'id'; @@ -20,7 +14,7 @@ class CatalogRuleDataGrid extends DataGrid public function prepareQueryBuilder() { $queryBuilder = DB::table('catalog_rules') - ->addSelect('catalog_rules.id', 'name', 'status', 'starts_from', 'ends_till', 'sort_order'); + ->addSelect('catalog_rules.id', 'name', 'status', 'starts_from', 'ends_till', 'sort_order'); $this->setQueryBuilder($queryBuilder); } @@ -28,80 +22,81 @@ class CatalogRuleDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'starts_from', - 'label' => trans('admin::app.datagrid.start'), - 'type' => 'datetime', - 'sortable' => true, - 'searchable' => false, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'ends_till', - 'label' => trans('admin::app.datagrid.end'), - 'type' => 'datetime', - 'sortable' => true, - 'searchable' => false, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'status', - 'label' => trans('admin::app.status'), - 'type' => 'boolean', - 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->status == 1) - return trans('admin::app.datagrid.active'); - else - return trans('admin::app.datagrid.inactive'); - } ]); $this->addColumn([ - 'index' => 'sort_order', - 'label' => trans('admin::app.datagrid.priority'), - 'type' => 'number', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'starts_from', + 'label' => trans('admin::app.datagrid.start'), + 'type' => 'datetime', + 'sortable' => true, + 'searchable' => false, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'ends_till', + 'label' => trans('admin::app.datagrid.end'), + 'type' => 'datetime', + 'sortable' => true, + 'searchable' => false, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'status', + 'label' => trans('admin::app.status'), + 'type' => 'boolean', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + 'wrapper' => function($value) { + if ($value->status == 1) { + return trans('admin::app.datagrid.active'); + } else { + return trans('admin::app.datagrid.inactive'); + } + }, + ]); + + $this->addColumn([ + 'index' => 'sort_order', + 'label' => trans('admin::app.datagrid.priority'), + 'type' => 'number', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Catalog Rule', + 'title' => 'Edit Catalog Rule', 'method' => 'GET', - 'route' => 'admin.catalog-rules.edit', - 'icon' => 'icon pencil-lg-icon' + 'route' => 'admin.catalog-rules.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Catalog Rule', + 'title' => 'Delete Catalog Rule', 'method' => 'POST', - 'route' => 'admin.catalog-rules.delete', - 'icon' => 'icon trash-icon' + 'route' => 'admin.catalog-rules.delete', + 'icon' => 'icon trash-icon', ]); } } diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 44b174a7b..9a1b56d49 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -2,32 +2,26 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * CategoryDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CategoryDataGrid extends DataGrid { - protected $index = 'category_id'; //the column that needs to be treated as index column + protected $index = 'category_id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { $queryBuilder = DB::table('categories as cat') - ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale', - DB::raw('COUNT(DISTINCT ' . DB::getTablePrefix() . 'pc.product_id) as count')) - ->leftJoin('category_translations as ct', function($leftJoin) { - $leftJoin->on('cat.id', '=', 'ct.category_id') - ->where('ct.locale', app()->getLocale()); - }) - ->leftJoin('product_categories as pc', 'cat.id', '=', 'pc.category_id') - ->groupBy('cat.id'); + ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale', + DB::raw('COUNT(DISTINCT ' . DB::getTablePrefix() . 'pc.product_id) as count')) + ->leftJoin('category_translations as ct', function($leftJoin) { + $leftJoin->on('cat.id', '=', 'ct.category_id') + ->where('ct.locale', app()->getLocale()); + }) + ->leftJoin('product_categories as pc', 'cat.id', '=', 'pc.category_id') + ->groupBy('cat.id'); $this->addFilter('category_id', 'cat.id'); @@ -38,71 +32,72 @@ class CategoryDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'category_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'category_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'position', - 'label' => trans('admin::app.datagrid.position'), - 'type' => 'number', + 'index' => 'position', + 'label' => trans('admin::app.datagrid.position'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'status', - 'label' => trans('admin::app.datagrid.status'), - 'type' => 'boolean', - 'sortable' => true, + 'index' => 'status', + 'label' => trans('admin::app.datagrid.status'), + 'type' => 'boolean', + 'sortable' => true, 'searchable' => true, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->status == 1) + 'wrapper' => function($value) { + if ($value->status == 1) { return 'Active'; - else + } else { return 'Inactive'; - } + } + }, ]); $this->addColumn([ - 'index' => 'count', - 'label' => trans('admin::app.datagrid.no-of-products'), - 'type' => 'number', - 'sortable' => true, + 'index' => 'count', + 'label' => trans('admin::app.datagrid.no-of-products'), + 'type' => 'number', + 'sortable' => true, 'searchable' => false, - 'filterable' => false + 'filterable' => false, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Category', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.catalog.categories.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Category', + 'method' => 'GET', + 'route' => 'admin.catalog.categories.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Category', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.catalog.categories.delete', + 'title' => 'Delete Category', + 'method' => 'POST', + 'route' => 'admin.catalog.categories.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php index faddf7634..84c0cd840 100755 --- a/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ChannelDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * ChannelDataGrid class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ChannelDataGrid extends DataGrid { - protected $index = 'id'; //the column that needs to be treated as index column + protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,56 +21,56 @@ class ChannelDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.code'), - 'type' => 'string', + 'index' => 'code', + 'label' => trans('admin::app.datagrid.code'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'hostname', - 'label' => trans('admin::app.datagrid.hostname'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'hostname', + 'label' => trans('admin::app.datagrid.hostname'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, - 'filterable' => true + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Channel', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.channels.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Channel', + 'method' => 'GET', + 'route' => 'admin.channels.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Channel', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.channels.delete', + 'title' => 'Delete Channel', + 'method' => 'POST', + 'route' => 'admin.channels.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CouponsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CouponsDataGrid.php index ea6c4b026..fc1a838d7 100644 --- a/packages/Webkul/Admin/src/DataGrids/CouponsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CouponsDataGrid.php @@ -2,26 +2,20 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * Cart Rule DataGrid class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CartRuleCouponsDataGrid extends DataGrid { - protected $index = 'id'; //the column that needs to be treated as index column + protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { $queryBuilder = DB::table('cart_rules') - ->select('id') - ->addSelect('id', 'code', 'limit', 'usage_per_customer', 'usage_throttle'); + ->select('id') + ->addSelect('id', 'code', 'limit', 'usage_per_customer', 'usage_throttle'); $this->setQueryBuilder($queryBuilder); } @@ -29,68 +23,55 @@ class CartRuleCouponsDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.code'), - 'type' => 'string', - 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'limit', - 'label' => trans('admin::app.datagrid.limit'), - 'type' => 'string', - 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'limit', - 'label' => trans('admin::app.datagrid.limit'), - 'type' => 'string', - 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'usage_per_customer', - 'label' => trans('admin::app.datagrid.usage-per-customer'), - 'type' => 'boolean', - 'searchable' => false, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->end_other_rules == 1) - return 'true'; - else - return 'false'; - } ]); - } - public function prepareActions() - { - } + $this->addColumn([ + 'index' => 'code', + 'label' => trans('admin::app.datagrid.code'), + 'type' => 'string', + 'searchable' => false, + 'sortable' => true, + 'filterable' => true, + ]); - public function prepareMassActions() - { - // $this->addMassAction([ - // 'type' => 'delete', - // 'action' => route('admin.catalog.attributes.massdelete'), - // 'label' => trans('admin::app.datagrid.delete'), - // 'method' => 'DELETE' - // ]); + $this->addColumn([ + 'index' => 'limit', + 'label' => trans('admin::app.datagrid.limit'), + 'type' => 'string', + 'searchable' => false, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'limit', + 'label' => trans('admin::app.datagrid.limit'), + 'type' => 'string', + 'searchable' => false, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'usage_per_customer', + 'label' => trans('admin::app.datagrid.usage-per-customer'), + 'type' => 'boolean', + 'searchable' => false, + 'sortable' => true, + 'filterable' => true, + 'wrapper' => function($value) { + if ($value->end_other_rules == 1) { + return 'true'; + } else { + return 'false'; + } + }, + ]); } } diff --git a/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php index 48810b6e8..6a1732231 100755 --- a/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CurrencyDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * CurrencyDataGrid class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CurrencyDataGrid extends DataGrid { - protected $index = 'id'; //the column that needs to be treated as index column + protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,46 +21,46 @@ class CurrencyDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.code'), - 'type' => 'string', + 'index' => 'code', + 'label' => trans('admin::app.datagrid.code'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Currency', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.currencies.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Currency', + 'method' => 'GET', + 'route' => 'admin.currencies.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Currency', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.currencies.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete Currency', + 'method' => 'POST', + 'route' => 'admin.currencies.delete', + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index 6ffaaa713..67fb54c3b 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -2,30 +2,23 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * CustomerDataGrid class - * - * @author Prashant Singh @prashant-webkul - * @author Vivek Sharma @viveksh-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CustomerDataGrid extends DataGrid { - protected $index = 'customer_id'; //the column that needs to be treated as index column + protected $index = 'customer_id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; protected $itemsPerPage = 10; public function prepareQueryBuilder() { $queryBuilder = DB::table('customers') - ->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id') - ->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'customers.phone', 'customers.gender', 'status') - ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name) as full_name')); + ->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id') + ->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'customers.phone', 'customers.gender', 'status') + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name) as full_name')); $this->addFilter('customer_id', 'customers.id'); $this->addFilter('full_name', DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name)')); @@ -38,119 +31,121 @@ class CustomerDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'customer_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'customer_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'full_name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'email', - 'label' => trans('admin::app.datagrid.email'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.group'), - 'type' => 'string', - 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'phone', - 'label' => trans('admin::app.datagrid.phone'), - 'type' => 'number', - 'searchable' => true, - 'sortable' => true, - 'filterable' => false, - 'closure' => true, - 'wrapper' => function ($row) { - if (! $row->phone) - return '-'; - else - return $row->phone; - } - ]); - - $this->addColumn([ - 'index' => 'gender', - 'label' => trans('admin::app.datagrid.gender'), - 'type' => 'string', - 'searchable' => false, - 'sortable' => true, - 'filterable' => false, - 'closure' => true, - 'wrapper' => function ($row) { - if (! $row->gender) - return '-'; - else - return $row->gender; - } - ]); - - $this->addColumn([ - 'index' => 'status', - 'label' => trans('admin::app.datagrid.status'), - 'type' => 'boolean', - 'searchable' => false, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'closure' => true, - 'wrapper' => function ($row) { + ]); + + $this->addColumn([ + 'index' => 'full_name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'email', + 'label' => trans('admin::app.datagrid.email'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'name', + 'label' => trans('admin::app.datagrid.group'), + 'type' => 'string', + 'searchable' => false, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'phone', + 'label' => trans('admin::app.datagrid.phone'), + 'type' => 'number', + 'searchable' => true, + 'sortable' => true, + 'filterable' => false, + 'closure' => true, + 'wrapper' => function ($row) { + if (! $row->phone) { + return '-'; + } else { + return $row->phone; + } + }, + ]); + + $this->addColumn([ + 'index' => 'gender', + 'label' => trans('admin::app.datagrid.gender'), + 'type' => 'string', + 'searchable' => false, + 'sortable' => true, + 'filterable' => false, + 'closure' => true, + 'wrapper' => function ($row) { + if (! $row->gender) { + return '-'; + } else { + return $row->gender; + } + }, + ]); + + $this->addColumn([ + 'index' => 'status', + 'label' => trans('admin::app.datagrid.status'), + 'type' => 'boolean', + 'searchable' => false, + 'sortable' => true, + 'filterable' => true, + 'closure' => true, + 'wrapper' => function ($row) { if ($row->status == 1) { return ''. trans('admin::app.customers.customers.active') .''; } else { return ''. trans('admin::app.customers.customers.inactive') .''; } - } + }, ]); } public function prepareActions() { $this->addAction([ - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.customer.edit', - 'icon' => 'icon pencil-lg-icon', - 'title' => trans('admin::app.customers.customers.edit-help-title') + 'method' => 'GET', + 'route' => 'admin.customer.edit', + 'icon' => 'icon pencil-lg-icon', + 'title' => trans('admin::app.customers.customers.edit-help-title'), ]); $this->addAction([ - 'type' => 'Edit', - 'method' => 'GET', //use post only for redirects only - 'route' => 'admin.customer.addresses.index', - 'icon' => 'icon list-icon', - 'title' => trans('admin::app.customers.customers.addresses') + 'type' => 'Edit', + 'method' => 'GET', + 'route' => 'admin.customer.addresses.index', + 'icon' => 'icon list-icon', + 'title' => trans('admin::app.customers.customers.addresses'), ]); $this->addAction([ - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.customer.delete', - 'icon' => 'icon trash-icon', - 'title' => trans('admin::app.customers.customers.delete-help-title') + 'method' => 'POST', + 'route' => 'admin.customer.delete', + 'icon' => 'icon trash-icon', + 'title' => trans('admin::app.customers.customers.delete-help-title'), ]); $this->addAction([ 'method' => 'GET', - 'route' => 'admin.customer.note.create', - 'icon' => 'icon note-icon', - 'title' => trans('admin::app.customers.note.help-title') + 'route' => 'admin.customer.note.create', + 'icon' => 'icon note-icon', + 'title' => trans('admin::app.customers.note.help-title'), ]); } @@ -160,23 +155,21 @@ class CustomerDataGrid extends DataGrid public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', - 'label' => trans('admin::app.datagrid.delete'), + 'type' => 'delete', + 'label' => trans('admin::app.datagrid.delete'), 'action' => route('admin.customer.mass-delete'), 'method' => 'PUT', ]); $this->addMassAction([ - 'type' => 'update', - 'label' => trans('admin::app.datagrid.update-status'), - 'action' => route('admin.customer.mass-update'), - 'method' => 'PUT', + 'type' => 'update', + 'label' => trans('admin::app.datagrid.update-status'), + 'action' => route('admin.customer.mass-update'), + 'method' => 'PUT', 'options' => [ - 'Active' => 1, - 'Inactive' => 0 - ] + 'Active' => 1, + 'Inactive' => 0, + ], ]); - - $this->enableMassAction = true; } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php index 77ae624de..4aaf6875a 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerGroupDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * CustomerDataGrid class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CustomerGroupDataGrid extends DataGrid { - protected $index = 'id'; //the column that needs to be treated as index column + protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,46 +21,46 @@ class CustomerGroupDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.code'), - 'type' => 'string', + 'index' => 'code', + 'label' => trans('admin::app.datagrid.code'), + 'type' => 'string', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Customer Group', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.groups.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Customer Group', + 'method' => 'GET', + 'route' => 'admin.groups.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Customer Group', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.groups.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete Customer Group', + 'method' => 'POST', + 'route' => 'admin.groups.delete', + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php index c5d71b4a1..7466deb77 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * CustomerReviewDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CustomerReviewDataGrid extends DataGrid { - protected $index = 'product_review_id'; //column that needs to be treated as index column + protected $index = 'product_review_id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -35,95 +29,96 @@ class CustomerReviewDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'product_review_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'product_review_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'title', - 'label' => trans('admin::app.datagrid.title'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'comment', - 'label' => trans('admin::app.datagrid.comment'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'product_name', - 'label' => trans('admin::app.datagrid.product-name'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => false - ]); - - $this->addColumn([ - 'index' => 'product_review_status', - 'label' => trans('admin::app.datagrid.status'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'width' => '100px', + 'sortable' => true, 'filterable' => true, - 'closure' => true, - 'wrapper' => function ($value) { - if ($value->product_review_status == 'approved') + ]); + + $this->addColumn([ + 'index' => 'title', + 'label' => trans('admin::app.datagrid.title'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'comment', + 'label' => trans('admin::app.datagrid.comment'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'product_name', + 'label' => trans('admin::app.datagrid.product-name'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => false, + ]); + + $this->addColumn([ + 'index' => 'product_review_status', + 'label' => trans('admin::app.datagrid.status'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'width' => '100px', + 'filterable' => true, + 'closure' => true, + 'wrapper' => function ($value) { + if ($value->product_review_status == 'approved') { return 'Approved'; - else if ($value->product_review_status == "pending") + } elseif ($value->product_review_status == "pending") { return 'Pending'; - else if ($value->product_review_status == "disapproved") + } elseif ($value->product_review_status == "disapproved") { return 'Disapproved'; + } }, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Customer Review', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.customer.review.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Customer Review', + 'method' => 'GET', + 'route' => 'admin.customer.review.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Customer Review', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.customer.review.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete Customer Review', + 'method' => 'POST', + 'route' => 'admin.customer.review.delete', + 'icon' => 'icon trash-icon', ]); } public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', - 'label' => trans('admin::app.datagrid.delete'), + 'type' => 'delete', + 'label' => trans('admin::app.datagrid.delete'), 'action' => route('admin.customer.review.massdelete'), - 'method' => 'DELETE' + 'method' => 'DELETE', ]); $this->addMassAction([ - 'type' => 'update', - 'label' => trans('admin::app.datagrid.update-status'), - 'action' => route('admin.customer.review.massupdate'), - 'method' => 'PUT', + 'type' => 'update', + 'label' => trans('admin::app.datagrid.update-status'), + 'action' => route('admin.customer.review.massupdate'), + 'method' => 'PUT', 'options' => [ - 'Pending' => 0, - 'Approve' => 1, - 'Disapprove' => 2 - ] + 'Pending' => 0, + 'Approve' => 1, + 'Disapprove' => 2, + ], ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php index 3357b34fc..9b212ed01 100755 --- a/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ExchangeRatesDataGrid.php @@ -2,24 +2,20 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * ExchangeRateDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ExchangeRatesDataGrid extends DataGrid { protected $index = 'currency_exch_id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('currency_exchange_rates as cer')->addSelect('cer.id as currency_exch_id', 'curr.name', 'cer.rate')->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id'); + $queryBuilder = DB::table('currency_exchange_rates as cer') + ->leftJoin('currencies as curr', 'cer.target_currency', '=', 'curr.id') + ->addSelect('cer.id as currency_exch_id', 'curr.name', 'cer.rate'); $this->addFilter('currency_exch_id', 'cer.id'); @@ -29,47 +25,47 @@ class ExchangeRatesDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'currency_exch_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'currency_exch_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.currency-name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.currency-name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'rate', - 'label' => trans('admin::app.datagrid.exch-rate'), - 'type' => 'number', + 'index' => 'rate', + 'label' => trans('admin::app.datagrid.exch-rate'), + 'type' => 'number', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Exchange Rate', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.exchange_rates.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Exchange Rate', + 'method' => 'GET', + 'route' => 'admin.exchange_rates.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Exchange Rate', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.exchange_rates.delete', + 'title' => 'Delete Exchange Rate', + 'method' => 'POST', + 'route' => 'admin.exchange_rates.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php index 018eb784a..7fce1af2d 100755 --- a/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/InventorySourcesDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * InventorySourcesDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class InventorySourcesDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,71 +21,72 @@ class InventorySourcesDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.code'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'priority', - 'label' => trans('admin::app.datagrid.priority'), - 'type' => 'number', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'status', - 'label' => trans('admin::app.datagrid.status'), - 'type' => 'boolean', - 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->status == 1) + ]); + + $this->addColumn([ + 'index' => 'code', + 'label' => trans('admin::app.datagrid.code'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'priority', + 'label' => trans('admin::app.datagrid.priority'), + 'type' => 'number', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'status', + 'label' => trans('admin::app.datagrid.status'), + 'type' => 'boolean', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + 'wrapper' => function($value) { + if ($value->status == 1) { return 'Active'; - else + } else { return 'Inactive'; - } + } + }, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Inventory Source', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.inventory_sources.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Inventory Source', + 'method' => 'GET', + 'route' => 'admin.inventory_sources.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Inventory Source', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.inventory_sources.delete', + 'title' => 'Delete Inventory Source', + 'method' => 'POST', + 'route' => 'admin.inventory_sources.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php index 59f13d130..e8d0277ab 100755 --- a/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/LocalesDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * LocalesDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class LocalesDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,63 +21,64 @@ class LocalesDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.code'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'direction', - 'label' => trans('admin::app.datagrid.direction'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'closure' => true, - 'wrapper' => function ($value) { - if ($value->direction == 'ltr') + ]); + + $this->addColumn([ + 'index' => 'code', + 'label' => trans('admin::app.datagrid.code'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'direction', + 'label' => trans('admin::app.datagrid.direction'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + 'closure' => true, + 'wrapper' => function ($value) { + if ($value->direction == 'ltr') { return trans('admin::app.datagrid.ltr'); - else + } else { return trans('admin::app.datagrid.rtl'); - } + } + }, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Locales', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.locales.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Locales', + 'method' => 'GET', + 'route' => 'admin.locales.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Locales', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.locales.delete', + 'title' => 'Delete Locales', + 'method' => 'POST', + 'route' => 'admin.locales.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php index acf76450c..0ec819e37 100755 --- a/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/NewsLetterDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * NewsLetterDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class NewsLetterDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,53 +21,54 @@ class NewsLetterDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'is_subscribed', - 'label' => trans('admin::app.datagrid.subscribed'), - 'type' => 'string', - 'searchable' => false, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->is_subscribed == 1) - return 'True'; - else - return 'False'; - } ]); $this->addColumn([ - 'index' => 'email', - 'label' => trans('admin::app.datagrid.email'), - 'type' => 'string', + 'index' => 'is_subscribed', + 'label' => trans('admin::app.datagrid.subscribed'), + 'type' => 'string', + 'searchable' => false, + 'sortable' => true, + 'filterable' => true, + 'wrapper' => function($value) { + if ($value->is_subscribed == 1) { + return 'True'; + } else { + return 'False'; + } + }, + ]); + + $this->addColumn([ + 'index' => 'email', + 'label' => trans('admin::app.datagrid.email'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit News Letter', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.customers.subscribers.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit News Letter', + 'method' => 'GET', + 'route' => 'admin.customers.subscribers.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete News Letter', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.customers.subscribers.delete', + 'title' => 'Delete News Letter', + 'method' => 'POST', + 'route' => 'admin.customers.subscribers.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'Exchange Rate']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index 6fefb315d..1cb9b03b1 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -2,35 +2,29 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * OrderDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class OrderDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { $queryBuilder = DB::table('orders') - ->leftJoin('order_address as order_address_shipping', function($leftJoin) { - $leftJoin->on('order_address_shipping.order_id', '=', 'orders.id') - ->where('order_address_shipping.address_type', 'shipping'); - }) - ->leftJoin('order_address as order_address_billing', function($leftJoin) { - $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') - ->where('order_address_billing.address_type', 'billing'); - }) - ->addSelect('orders.id','orders.increment_id', 'orders.base_sub_total', 'orders.base_grand_total', 'orders.created_at', 'channel_name', 'status') - ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')) - ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')); + ->leftJoin('order_address as order_address_shipping', function($leftJoin) { + $leftJoin->on('order_address_shipping.order_id', '=', 'orders.id') + ->where('order_address_shipping.address_type', 'shipping'); + }) + ->leftJoin('order_address as order_address_billing', function($leftJoin) { + $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') + ->where('order_address_billing.address_type', 'billing'); + }) + ->addSelect('orders.id','orders.increment_id', 'orders.base_sub_total', 'orders.base_grand_total', 'orders.created_at', 'channel_name', 'status') + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')) + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')); $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); $this->addFilter('shipped_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name)')); @@ -43,101 +37,102 @@ class OrderDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'increment_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'string', + 'index' => 'increment_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'string', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'base_sub_total', - 'label' => trans('admin::app.datagrid.sub-total'), - 'type' => 'price', + 'index' => 'base_sub_total', + 'label' => trans('admin::app.datagrid.sub-total'), + 'type' => 'price', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'base_grand_total', - 'label' => trans('admin::app.datagrid.grand-total'), - 'type' => 'price', + 'index' => 'base_grand_total', + 'label' => trans('admin::app.datagrid.grand-total'), + 'type' => 'price', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'created_at', - 'label' => trans('admin::app.datagrid.order-date'), - 'type' => 'datetime', - 'sortable' => true, + 'index' => 'created_at', + 'label' => trans('admin::app.datagrid.order-date'), + 'type' => 'datetime', + 'sortable' => true, 'searchable' => false, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'channel_name', - 'label' => trans('admin::app.datagrid.channel-name'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'channel_name', + 'label' => trans('admin::app.datagrid.channel-name'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'status', - 'label' => trans('admin::app.datagrid.status'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'status', + 'label' => trans('admin::app.datagrid.status'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, - 'closure' => true, + 'closure' => true, 'filterable' => true, 'wrapper' => function ($value) { - if ($value->status == 'processing') + if ($value->status == 'processing') { return ''. trans('admin::app.sales.orders.order-status-processing') .''; - else if ($value->status == 'completed') + } elseif ($value->status == 'completed') { return ''. trans('admin::app.sales.orders.order-status-success') .''; - else if ($value->status == "canceled") + } elseif ($value->status == "canceled") { return ''. trans('admin::app.sales.orders.order-status-canceled') .''; - else if ($value->status == "closed") + } elseif ($value->status == "closed") { return ''. trans('admin::app.sales.orders.order-status-closed') .''; - else if ($value->status == "pending") + } elseif ($value->status == "pending") { return ''. trans('admin::app.sales.orders.order-status-pending') .''; - else if ($value->status == "pending_payment") + } elseif ($value->status == "pending_payment") { return ''. trans('admin::app.sales.orders.order-status-pending-payment') .''; - else if ($value->status == "fraud") + } elseif ($value->status == "fraud") { return ''. trans('admin::app.sales.orders.order-status-fraud') . ''; - } + } + }, ]); $this->addColumn([ - 'index' => 'billed_to', - 'label' => trans('admin::app.datagrid.billed-to'), - 'type' => 'string', + 'index' => 'billed_to', + 'label' => trans('admin::app.datagrid.billed-to'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'shipped_to', - 'label' => trans('admin::app.datagrid.shipped-to'), - 'type' => 'string', + 'index' => 'shipped_to', + 'label' => trans('admin::app.datagrid.shipped-to'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Order View', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.sales.orders.view', - 'icon' => 'icon eye-icon' + 'title' => 'Order View', + 'method' => 'GET', + 'route' => 'admin.sales.orders.view', + 'icon' => 'icon eye-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php index 06a218085..357d2e9c8 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderInvoicesDataGrid.php @@ -2,26 +2,20 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * OrderInvoicesDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class OrderInvoicesDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { $queryBuilder = DB::table('invoices') - ->leftJoin('orders as ors', 'invoices.order_id', '=', 'ors.id') - ->select('invoices.id as id', 'ors.increment_id as order_id', 'invoices.state as state', 'invoices.base_grand_total as base_grand_total', 'invoices.created_at as created_at'); + ->leftJoin('orders as ors', 'invoices.order_id', '=', 'ors.id') + ->select('invoices.id as id', 'ors.increment_id as order_id', 'invoices.state as state', 'invoices.base_grand_total as base_grand_total', 'invoices.created_at as created_at'); $this->addFilter('id', 'invoices.id'); $this->addFilter('order_id', 'ors.increment_id'); @@ -34,48 +28,48 @@ class OrderInvoicesDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'order_id', - 'label' => trans('admin::app.datagrid.order-id'), - 'type' => 'string', + 'index' => 'order_id', + 'label' => trans('admin::app.datagrid.order-id'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'base_grand_total', - 'label' => trans('admin::app.datagrid.grand-total'), - 'type' => 'price', + 'index' => 'base_grand_total', + 'label' => trans('admin::app.datagrid.grand-total'), + 'type' => 'price', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'created_at', - 'label' => trans('admin::app.datagrid.invoice-date'), - 'type' => 'datetime', + 'index' => 'created_at', + 'label' => trans('admin::app.datagrid.invoice-date'), + 'type' => 'datetime', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Order Invoice View', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.sales.invoices.view', - 'icon' => 'icon eye-icon' + 'title' => 'Order Invoice View', + 'method' => 'GET', + 'route' => 'admin.sales.invoices.view', + 'icon' => 'icon eye-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php index 787b1512e..bd2e8590f 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php @@ -2,31 +2,25 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * OrderRefundDataGrid Class - * - * @author Prashant Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class OrderRefundDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { $queryBuilder = DB::table('refunds') - ->select('refunds.id', 'orders.increment_id', 'refunds.state', 'refunds.base_grand_total', 'refunds.created_at') - ->leftJoin('orders', 'refunds.order_id', '=', 'orders.id') - ->leftJoin('order_address as order_address_billing', function($leftJoin) { - $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') - ->where('order_address_billing.address_type', 'billing'); - }) - ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')); + ->select('refunds.id', 'orders.increment_id', 'refunds.state', 'refunds.base_grand_total', 'refunds.created_at') + ->leftJoin('orders', 'refunds.order_id', '=', 'orders.id') + ->leftJoin('order_address as order_address_billing', function($leftJoin) { + $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') + ->where('order_address_billing.address_type', 'billing'); + }) + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')); $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); $this->addFilter('id', 'refunds.id'); @@ -41,57 +35,57 @@ class OrderRefundDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'increment_id', - 'label' => trans('admin::app.datagrid.order-id'), - 'type' => 'string', + 'index' => 'increment_id', + 'label' => trans('admin::app.datagrid.order-id'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'base_grand_total', - 'label' => trans('admin::app.datagrid.refunded'), - 'type' => 'price', + 'index' => 'base_grand_total', + 'label' => trans('admin::app.datagrid.refunded'), + 'type' => 'price', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'billed_to', - 'label' => trans('admin::app.datagrid.billed-to'), - 'type' => 'string', + 'index' => 'billed_to', + 'label' => trans('admin::app.datagrid.billed-to'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'created_at', - 'label' => trans('admin::app.datagrid.refund-date'), - 'type' => 'datetime', + 'index' => 'created_at', + 'label' => trans('admin::app.datagrid.refund-date'), + 'type' => 'datetime', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Order Refund View', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.sales.refunds.view', - 'icon' => 'icon eye-icon' + 'title' => 'Order Refund View', + 'method' => 'GET', + 'route' => 'admin.sales.refunds.view', + 'icon' => 'icon eye-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index a254af897..cbaf55341 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -2,33 +2,27 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * OrderShipmentsDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class OrderShipmentsDataGrid extends DataGrid { protected $index = 'shipment_id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { $queryBuilder = DB::table('shipments') - ->leftJoin('order_address as order_address_shipping', function($leftJoin) { - $leftJoin->on('order_address_shipping.order_id', '=', 'shipments.order_id') - ->where('order_address_shipping.address_type', 'shipping'); - }) - ->leftJoin('orders as ors', 'shipments.order_id', '=', 'ors.id') - ->leftJoin('inventory_sources as is', 'shipments.inventory_source_id', '=', 'is.id') - ->select('shipments.id as shipment_id', 'ors.increment_id as shipment_order_id', 'shipments.total_qty as shipment_total_qty', 'ors.created_at as order_date', 'shipments.created_at as shipment_created_at') - ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')) - ->selectRaw('IF(' . DB::getTablePrefix() . 'shipments.inventory_source_id IS NOT NULL,' . DB::getTablePrefix() . 'is.name, ' . DB::getTablePrefix() . 'shipments.inventory_source_name) as inventory_source_name'); + ->leftJoin('order_address as order_address_shipping', function($leftJoin) { + $leftJoin->on('order_address_shipping.order_id', '=', 'shipments.order_id') + ->where('order_address_shipping.address_type', 'shipping'); + }) + ->leftJoin('orders as ors', 'shipments.order_id', '=', 'ors.id') + ->leftJoin('inventory_sources as is', 'shipments.inventory_source_id', '=', 'is.id') + ->select('shipments.id as shipment_id', 'ors.increment_id as shipment_order_id', 'shipments.total_qty as shipment_total_qty', 'ors.created_at as order_date', 'shipments.created_at as shipment_created_at') + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')) + ->selectRaw('IF(' . DB::getTablePrefix() . 'shipments.inventory_source_id IS NOT NULL,' . DB::getTablePrefix() . 'is.name, ' . DB::getTablePrefix() . 'shipments.inventory_source_name) as inventory_source_name'); $this->addFilter('shipment_id', 'shipments.id'); $this->addFilter('shipment_order_id', 'ors.increment_id'); @@ -44,75 +38,75 @@ class OrderShipmentsDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'shipment_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'shipment_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'shipment_order_id', - 'label' => trans('admin::app.datagrid.order-id'), - 'type' => 'string', + 'index' => 'shipment_order_id', + 'label' => trans('admin::app.datagrid.order-id'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'shipment_total_qty', - 'label' => trans('admin::app.datagrid.total-qty'), - 'type' => 'number', + 'index' => 'shipment_total_qty', + 'label' => trans('admin::app.datagrid.total-qty'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'inventory_source_name', - 'label' => trans('admin::app.datagrid.inventory-source'), - 'type' => 'string', + 'index' => 'inventory_source_name', + 'label' => trans('admin::app.datagrid.inventory-source'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'order_date', - 'label' => trans('admin::app.datagrid.order-date'), - 'type' => 'datetime', - 'sortable' => true, + 'index' => 'order_date', + 'label' => trans('admin::app.datagrid.order-date'), + 'type' => 'datetime', + 'sortable' => true, 'searchable' => false, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'shipment_created_at', - 'label' => trans('admin::app.datagrid.shipment-date'), - 'type' => 'datetime', - 'sortable' => true, + 'index' => 'shipment_created_at', + 'label' => trans('admin::app.datagrid.shipment-date'), + 'type' => 'datetime', + 'sortable' => true, 'searchable' => false, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'shipped_to', - 'label' => trans('admin::app.datagrid.shipment-to'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'shipped_to', + 'label' => trans('admin::app.datagrid.shipment-to'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, - 'filterable' => true + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Order Shipment View', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.sales.shipments.view', - 'icon' => 'icon eye-icon' + 'title' => 'Order Shipment View', + 'method' => 'GET', + 'route' => 'admin.sales.shipments.view', + 'icon' => 'icon eye-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index edf8dcd2e..55827b319 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -5,15 +5,9 @@ namespace Webkul\Admin\DataGrids; use Webkul\Ui\DataGrid\DataGrid; use Illuminate\Support\Facades\DB; -/** - * ProductDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ProductDataGrid extends DataGrid { - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; protected $index = 'product_id'; @@ -28,25 +22,26 @@ class ProductDataGrid extends DataGrid parent::__construct(); $this->locale = request()->get('locale') ?? 'all'; + $this->channel = request()->get('channel') ?? 'all'; } public function prepareQueryBuilder() { $queryBuilder = DB::table('product_flat') - ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') - ->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id') - ->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id') - ->select( - 'product_flat.product_id as product_id', - 'products.sku as product_sku', - 'product_flat.name as product_name', - 'products.type as product_type', - 'product_flat.status', - 'product_flat.price', - 'attribute_families.name as attribute_family', - DB::raw('SUM(DISTINCT ' . DB::getTablePrefix() . 'product_inventories.qty) as quantity') - ); + ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') + ->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id') + ->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id') + ->select( + 'product_flat.product_id as product_id', + 'products.sku as product_sku', + 'product_flat.name as product_name', + 'products.type as product_type', + 'product_flat.status', + 'product_flat.price', + 'attribute_families.name as attribute_family', + DB::raw('SUM(DISTINCT ' . DB::getTablePrefix() . 'product_inventories.qty) as quantity') + ); if ($this->locale !== 'all') { $queryBuilder->where('locale', $this->locale); @@ -73,131 +68,129 @@ class ProductDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'product_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'product_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'product_sku', - 'label' => trans('admin::app.datagrid.sku'), - 'type' => 'string', + 'index' => 'product_sku', + 'label' => trans('admin::app.datagrid.sku'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'product_name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', + 'index' => 'product_name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'attribute_family', - 'label' => trans('admin::app.datagrid.attribute-family'), - 'type' => 'string', + 'index' => 'attribute_family', + 'label' => trans('admin::app.datagrid.attribute-family'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'product_type', - 'label' => trans('admin::app.datagrid.type'), - 'type' => 'string', - 'sortable' => true, + 'index' => 'product_type', + 'label' => trans('admin::app.datagrid.type'), + 'type' => 'string', + 'sortable' => true, 'searchable' => true, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'status', - 'label' => trans('admin::app.datagrid.status'), - 'type' => 'boolean', - 'sortable' => true, + 'index' => 'status', + 'label' => trans('admin::app.datagrid.status'), + 'type' => 'boolean', + 'sortable' => true, 'searchable' => false, 'filterable' => true, - 'wrapper' => function($value) { - if ($value->status == 1) + 'wrapper' => function($value) { + if ($value->status == 1) { return 'Active'; - else + } else { return 'Inactive'; - } + } + }, ]); $this->addColumn([ - 'index' => 'price', - 'label' => trans('admin::app.datagrid.price'), - 'type' => 'price', - 'sortable' => true, + 'index' => 'price', + 'label' => trans('admin::app.datagrid.price'), + 'type' => 'price', + 'sortable' => true, 'searchable' => false, - 'filterable' => true + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'quantity', - 'label' => trans('admin::app.datagrid.qty'), - 'type' => 'number', - 'sortable' => true, + 'index' => 'quantity', + 'label' => trans('admin::app.datagrid.qty'), + 'type' => 'number', + 'sortable' => true, 'searchable' => false, 'filterable' => false, - 'wrapper' => function($value) { - if (is_null($value->quantity)) + 'wrapper' => function($value) { + if (is_null($value->quantity)) { return 0; - else + } else { return $value->quantity; - } + } + }, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Product', + 'title' => 'Edit Product', + 'method' => 'GET', + 'route' => 'admin.catalog.products.edit', + 'icon' => 'icon pencil-lg-icon', 'condition' => function() { return true; }, - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.catalog.products.edit', - 'icon' => 'icon pencil-lg-icon' ]); $this->addAction([ - 'title' => 'Delete Product', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.catalog.products.delete', + 'title' => 'Delete Product', + 'method' => 'POST', + 'route' => 'admin.catalog.products.delete', 'confirm_text' => trans('ui::app.datagrid.massaction.delete', ['resource' => 'product']), - 'icon' => 'icon trash-icon' + 'icon' => 'icon trash-icon', ]); - - $this->enableAction = true; } public function prepareMassActions() { $this->addMassAction([ - 'type' => 'delete', - 'label' => trans('admin::app.datagrid.delete'), + 'type' => 'delete', + 'label' => trans('admin::app.datagrid.delete'), 'action' => route('admin.catalog.products.massdelete'), - 'method' => 'DELETE' + 'method' => 'DELETE', ]); $this->addMassAction([ - 'type' => 'update', - 'label' => trans('admin::app.datagrid.update-status'), - 'action' => route('admin.catalog.products.massupdate'), - 'method' => 'PUT', + 'type' => 'update', + 'label' => trans('admin::app.datagrid.update-status'), + 'action' => route('admin.catalog.products.massupdate'), + 'method' => 'PUT', 'options' => [ - 'Active' => 1, - 'Inactive' => 0 - ] + 'Active' => 1, + 'Inactive' => 0, + ], ]); - - $this->enableMassAction = true; } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php b/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php index 1dde27f2e..a262a2f86 100755 --- a/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/RolesDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * RolesDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class RolesDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,47 +21,47 @@ class RolesDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'width' => '40px', - 'filterable' => true + 'sortable' => true, + 'width' => '40px', + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'permission_type', - 'label' => trans('admin::app.datagrid.permission-type'), - 'type' => 'string', + 'index' => 'permission_type', + 'label' => trans('admin::app.datagrid.permission-type'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.roles.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit', + 'method' => 'GET', + 'route' => 'admin.roles.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.roles.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete', + 'method' => 'POST', + 'route' => 'admin.roles.delete', + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php index 830bd003c..65449f660 100755 --- a/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/SliderDataGrid.php @@ -2,25 +2,20 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * SliderDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class SliderDataGrid extends DataGrid { protected $index = 'slider_id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('sliders as sl')->addSelect('sl.id as slider_id', 'sl.title', 'ch.name')->leftJoin('channels as ch', 'sl.channel_id', '=', - 'ch.id'); + $queryBuilder = DB::table('sliders as sl') + ->addSelect('sl.id as slider_id', 'sl.title', 'ch.name') + ->leftJoin('channels as ch', 'sl.channel_id', '=', 'ch.id'); $this->addFilter('slider_id', 'sl.id'); $this->addFilter('channel_name', 'ch.name'); @@ -31,46 +26,46 @@ class SliderDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'slider_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'slider_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'title', - 'label' => trans('admin::app.datagrid.title'), - 'type' => 'string', + 'index' => 'title', + 'label' => trans('admin::app.datagrid.title'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.channel-name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.channel-name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Slider', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.sliders.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Slider', + 'method' => 'GET', + 'route' => 'admin.sliders.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Slider', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.sliders.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete Slider', + 'method' => 'POST', + 'route' => 'admin.sliders.delete', + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php index 948fc6372..58f477e3b 100755 --- a/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxCategoryDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * TaxCategoryDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class TaxCategoryDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,46 +21,46 @@ class TaxCategoryDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', + 'index' => 'name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'code', - 'label' => trans('admin::app.datagrid.code'), - 'type' => 'string', + 'index' => 'code', + 'label' => trans('admin::app.datagrid.code'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Tax Category', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.tax-categories.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Tax Category', + 'method' => 'GET', + 'route' => 'admin.tax-categories.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Tax Category', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.tax-categories.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete Tax Category', + 'method' => 'POST', + 'route' => 'admin.tax-categories.delete', + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php index 8812bc2ba..2bb325f2b 100755 --- a/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/TaxRateDataGrid.php @@ -2,20 +2,14 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * TaxRateDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class TaxRateDataGrid extends DataGrid { protected $index = 'id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { @@ -27,97 +21,98 @@ class TaxRateDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'identifier', - 'label' => trans('admin::app.datagrid.identifier'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'state', - 'label' => trans('admin::app.datagrid.state'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'wrapper' => function($value) { - if (empty($value->state)) + ]); + + $this->addColumn([ + 'index' => 'identifier', + 'label' => trans('admin::app.datagrid.identifier'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'state', + 'label' => trans('admin::app.datagrid.state'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + 'wrapper' => function($value) { + if (empty($value->state)) { return '*'; - else + } else { return $value->state; - } + } + }, ]); $this->addColumn([ - 'index' => 'country', - 'label' => trans('admin::app.datagrid.country'), - 'type' => 'string', + 'index' => 'country', + 'label' => trans('admin::app.datagrid.country'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'zip_code', - 'label' => trans('admin::app.configuration.tax-rates.zip_code'), - 'type' => 'string', + 'index' => 'zip_code', + 'label' => trans('admin::app.configuration.tax-rates.zip_code'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'zip_from', - 'label' => trans('admin::app.configuration.tax-rates.zip_from'), - 'type' => 'string', + 'index' => 'zip_from', + 'label' => trans('admin::app.configuration.tax-rates.zip_from'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'zip_to', - 'label' => trans('admin::app.configuration.tax-rates.zip_to'), - 'type' => 'string', + 'index' => 'zip_to', + 'label' => trans('admin::app.configuration.tax-rates.zip_to'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'tax_rate', - 'label' => trans('admin::app.datagrid.tax-rate'), - 'type' => 'number', + 'index' => 'tax_rate', + 'label' => trans('admin::app.datagrid.tax-rate'), + 'type' => 'number', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit Tax Rate', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.tax-rates.store', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit Tax Rate', + 'method' => 'GET', + 'route' => 'admin.tax-rates.store', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete Tax Rate', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.tax-rates.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete Tax Rate', + 'method' => 'POST', + 'route' => 'admin.tax-rates.delete', + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php index e145de46a..c342ee437 100755 --- a/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/UserDataGrid.php @@ -2,24 +2,20 @@ namespace Webkul\Admin\DataGrids; +use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; -use DB; -/** - * UserDataGrid Class - * - * @author Prashant Singh @prashant-webkul - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class UserDataGrid extends DataGrid { protected $index = 'user_id'; - protected $sortOrder = 'desc'; //asc or desc + protected $sortOrder = 'desc'; public function prepareQueryBuilder() { - $queryBuilder = DB::table('admins as u')->addSelect('u.id as user_id', 'u.name as user_name', 'u.status', 'u.email', 'ro.name as role_name')->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id'); + $queryBuilder = DB::table('admins as u') + ->leftJoin('roles as ro', 'u.role_id', '=', 'ro.id') + ->addSelect('u.id as user_id', 'u.name as user_name', 'u.status', 'u.email', 'ro.name as role_name'); $this->addFilter('user_id', 'u.id'); $this->addFilter('user_name', 'u.name'); @@ -31,71 +27,71 @@ class UserDataGrid extends DataGrid public function addColumns() { $this->addColumn([ - 'index' => 'user_id', - 'label' => trans('admin::app.datagrid.id'), - 'type' => 'number', + 'index' => 'user_id', + 'label' => trans('admin::app.datagrid.id'), + 'type' => 'number', 'searchable' => false, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'user_name', - 'label' => trans('admin::app.datagrid.name'), - 'type' => 'string', - 'searchable' => true, - 'sortable' => true, - 'filterable' => true - ]); - - $this->addColumn([ - 'index' => 'status', - 'label' => trans('admin::app.datagrid.status'), - 'type' => 'boolean', - 'searchable' => true, - 'sortable' => true, + 'sortable' => true, 'filterable' => true, - 'wrapper' => function($value) { + ]); + + $this->addColumn([ + 'index' => 'user_name', + 'label' => trans('admin::app.datagrid.name'), + 'type' => 'string', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + ]); + + $this->addColumn([ + 'index' => 'status', + 'label' => trans('admin::app.datagrid.status'), + 'type' => 'boolean', + 'searchable' => true, + 'sortable' => true, + 'filterable' => true, + 'wrapper' => function($value) { if ($value->status == 1) { return 'Active'; } else { return 'Inactive'; } - } + }, ]); $this->addColumn([ - 'index' => 'email', - 'label' => trans('admin::app.datagrid.email'), - 'type' => 'string', + 'index' => 'email', + 'label' => trans('admin::app.datagrid.email'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); $this->addColumn([ - 'index' => 'role_name', - 'label' => trans('admin::app.datagrid.role'), - 'type' => 'string', + 'index' => 'role_name', + 'label' => trans('admin::app.datagrid.role'), + 'type' => 'string', 'searchable' => true, - 'sortable' => true, - 'filterable' => true + 'sortable' => true, + 'filterable' => true, ]); } public function prepareActions() { $this->addAction([ - 'title' => 'Edit User', - 'method' => 'GET', // use GET request only for redirect purposes - 'route' => 'admin.users.edit', - 'icon' => 'icon pencil-lg-icon' + 'title' => 'Edit User', + 'method' => 'GET', + 'route' => 'admin.users.edit', + 'icon' => 'icon pencil-lg-icon', ]); $this->addAction([ - 'title' => 'Delete User', - 'method' => 'POST', // use GET request only for redirect purposes - 'route' => 'admin.users.delete', - 'icon' => 'icon trash-icon' + 'title' => 'Delete User', + 'method' => 'POST', + 'route' => 'admin.users.delete', + 'icon' => 'icon trash-icon', ]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Exceptions/Handler.php b/packages/Webkul/Admin/src/Exceptions/Handler.php index cfbf7c63d..42328c22b 100755 --- a/packages/Webkul/Admin/src/Exceptions/Handler.php +++ b/packages/Webkul/Admin/src/Exceptions/Handler.php @@ -5,7 +5,6 @@ namespace Webkul\Admin\Exceptions; use Exception; use Illuminate\Auth\AuthenticationException; use Illuminate\Database\Eloquent\PDOException; -use Illuminate\Database\Eloquent\ErrorException; use Illuminate\Database\Eloquent\ModelNotFoundException; use Symfony\Component\HttpKernel\Exception\HttpException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; @@ -23,7 +22,7 @@ class Handler extends ExceptionHandler * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request - * @param \Exception $exception + * @param \Exception $exception * @return \Illuminate\Http\Response */ public function render($request, Exception $exception) @@ -34,9 +33,9 @@ class Handler extends ExceptionHandler $statusCode = in_array($exception->getStatusCode(), [401, 403, 404, 503]) ? $exception->getStatusCode() : 500; return $this->response($path, $statusCode); - } else if ($exception instanceof ModelNotFoundException) { + } elseif ($exception instanceof ModelNotFoundException) { return $this->response($path, 404); - } else if ($exception instanceof PDOException) { + } elseif ($exception instanceof PDOException) { return $this->response($path, 500); } @@ -68,10 +67,10 @@ class Handler extends ExceptionHandler { if (request()->expectsJson()) { return response()->json([ - 'error' => isset($this->jsonErrorMessages[$statusCode]) - ? $this->jsonErrorMessages[$statusCode] - : 'Something went wrong, please try again later.' - ], $statusCode); + 'error' => isset($this->jsonErrorMessages[$statusCode]) + ? $this->jsonErrorMessages[$statusCode] + : 'Something went wrong, please try again later.' + ], $statusCode); } return response()->view("{$path}::errors.{$statusCode}", [], $statusCode); diff --git a/packages/Webkul/Admin/src/Exports/DataGridExport.php b/packages/Webkul/Admin/src/Exports/DataGridExport.php index 9b6289b1e..42a7d1974 100755 --- a/packages/Webkul/Admin/src/Exports/DataGridExport.php +++ b/packages/Webkul/Admin/src/Exports/DataGridExport.php @@ -6,22 +6,14 @@ use Illuminate\Contracts\View\View; use Maatwebsite\Excel\Concerns\FromView; use Maatwebsite\Excel\Concerns\ShouldAutoSize; -/** - * DataGridExport class - * - * @author Rahul Shukla - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ - class DataGridExport implements FromView, ShouldAutoSize { - /** * DataGrid instance * * @var mixed */ - protected $gridData = array(); + protected $gridData = []; /** * Create a new instance. @@ -40,7 +32,7 @@ class DataGridExport implements FromView, ShouldAutoSize */ public function view(): View { - $columns = array(); + $columns = []; foreach($this->gridData as $key => $gridData) { $columns = array_keys((array) $gridData); diff --git a/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php b/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php index 5accd15e6..b62228784 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/ConfigurationController.php @@ -8,12 +8,6 @@ use Webkul\Core\Tree; use Illuminate\Support\Facades\Storage; use Webkul\Admin\Http\Requests\ConfigurationForm; -/** - * Configuration controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ConfigurationController extends Controller { /** @@ -26,7 +20,7 @@ class ConfigurationController extends Controller /** * CoreConfigRepository object * - * @var array + * @var \Webkul\Core\Repositories\CoreConfigRepository */ protected $coreConfigRepository; @@ -39,7 +33,7 @@ class ConfigurationController extends Controller /** * Create a new controller instance. * - * @param \Webkul\Core\Repositories\CoreConfigRepository $coreConfigRepository + * @param \Webkul\Core\Repositories\CoreConfigRepository $coreConfigRepository * @return void */ public function __construct(CoreConfigRepository $coreConfigRepository) @@ -51,7 +45,6 @@ class ConfigurationController extends Controller $this->_config = request('_config'); $this->prepareConfigTree(); - } /** @@ -114,7 +107,7 @@ class ConfigurationController extends Controller /** * Store a newly created resource in storage. * - * @param \Webkul\Admin\Http\Requests\ConfigurationForm $request + * @param \Webkul\Admin\Http\Requests\ConfigurationForm $request * @return \Illuminate\Http\Response */ public function store(ConfigurationForm $request) @@ -147,8 +140,7 @@ class ConfigurationController extends Controller } /** - * @param $secondItem - * + * @param string $secondItem * @return array */ private function getSlugs($secondItem): array diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/AddressController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/AddressController.php index d44921463..459a7af52 100644 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/AddressController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/AddressController.php @@ -4,15 +4,9 @@ namespace Webkul\Admin\Http\Controllers\Customer; use Webkul\Customer\Rules\VatIdRule; use Webkul\Admin\Http\Controllers\Controller; -use Webkul\Customer\Repositories\CustomerRepository as Customer; -use Webkul\Customer\Repositories\CustomerAddressRepository as CustomerAddress; +use Webkul\Customer\Repositories\CustomerRepository; +use Webkul\Customer\Repositories\CustomerAddressRepository; -/** - * Customer's Address controller - * - * @author Vivek Sharma - * @copyright 2019 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AddressController extends Controller { /** @@ -25,32 +19,32 @@ class AddressController extends Controller /** * Customer Repository object * - * @var object + * @var \Webkul\Customer\Repositories\CustomerRepository */ - protected $customer; + protected $customerRepository; /** * CustomerAddress Repository object * - * @var object + * @var \Webkul\Customer\Repositories\CustomerAddressRepository */ - protected $customerAddress; + protected $customerAddressRepository; /** * Create a new controller instance. * - * @param Webkul\Customer\Repositories\CustomerAddressRepository $customerAddress - * + * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository + * @param \Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository * @return void */ public function __construct( - Customer $customer, - CustomerAddress $customerAddress + CustomerRepository $customerRepository, + CustomerAddressRepository $customerAddressRepository ) { - $this->customer = $customer; + $this->customerRepository = $customerRepository; - $this->customerAddress = $customerAddress; + $this->customerAddressRepository = $customerAddressRepository; $this->_config = request('_config'); } @@ -58,11 +52,12 @@ class AddressController extends Controller /** * Method to populate the seller order page which will be populated. * - * @return Mixed + * @param int $id + * @return \Illuminate\View\View */ public function index($id) { - $customer = $this->customer->find($id); + $customer = $this->customerRepository->find($id); return view($this->_config['view'], compact('customer')); } @@ -70,11 +65,12 @@ class AddressController extends Controller /** * Show the form for creating a new resource. * - * @return \Illuminate\Http\Response + * @param int $id + * @return \Illuminate\View\View */ public function create($id) { - $customer = $this->customer->find($id); + $customer = $this->customerRepository->find($id); return view($this->_config['view'], compact('customer')); } @@ -103,7 +99,7 @@ class AddressController extends Controller 'vat_id' => new VatIdRule(), ]); - if ($this->customerAddress->create($data)) { + if ($this->customerAddressRepository->create($data)) { session()->flash('success', trans('admin::app.customers.addresses.success-create')); return redirect()->route('admin.customer.addresses.index', ['id' => $data['customer_id']]); @@ -117,20 +113,21 @@ class AddressController extends Controller /** * Display a listing of the resource. * - * @return Mixed + * @param int $id + * @return \Illuminate\View\View */ public function edit($id) { - $address = $this->customerAddress->find($id); + $address = $this->customerAddressRepository->find($id); return view($this->_config['view'], compact('address')); } /** - * Edit's the premade resource of customer called - * Address. + * Edit's the premade resource of customer called Address. * - * @return redirect + * @param int $id + * @return \Illuminate\Http\Response */ public function update($id) { @@ -149,11 +146,10 @@ class AddressController extends Controller $data = collect(request()->input())->except('_token')->toArray(); - $address = $this->customerAddress->find($id); + $address = $this->customerAddressRepository->find($id); if ($address) { - - $this->customerAddress->update($data, $id); + $this->customerAddressRepository->update($data, $id); session()->flash('success', trans('admin::app.customers.addresses.success-update')); @@ -165,13 +161,12 @@ class AddressController extends Controller /** * Remove the specified resource from storage. * - * @param int $id - * + * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { - $this->customerAddress->delete($id); + $this->customerAddressRepository->delete($id); session()->flash('success', trans('admin::app.customers.addresses.success-delete')); @@ -181,14 +176,15 @@ class AddressController extends Controller /** * Mass Delete the customer's addresses * - * @return response + * @param int $id + * @return \Illuminate\Http\Response */ public function massDestroy($id) { $addressIds = explode(',', request()->input('indexes')); foreach ($addressIds as $addressId) { - $this->customerAddress->delete($addressId); + $this->customerAddressRepository->delete($addressId); } session()->flash('success', trans('admin::app.customers.addresses.success-mass-delete')); diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php index 60edb2f32..98cbb7072 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerController.php @@ -9,12 +9,6 @@ use Webkul\Core\Repositories\ChannelRepository; use Webkul\Admin\Mail\NewCustomerNotification; use Mail; -/** - * Customer controlller - * - * @author Rahul Shukla - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CustomerController extends Controller { /** @@ -27,30 +21,30 @@ class CustomerController extends Controller /** * CustomerRepository object * - * @var array + * @var \Webkul\Customer\Repositories\CustomerRepository */ protected $customerRepository; /** * CustomerGroupRepository object * - * @var array + * @var \Webkul\Customer\Repositories\CustomerGroupRepository */ protected $customerGroupRepository; /** * ChannelRepository object * - * @var array + * @var \Webkul\Core\Repositories\ChannelRepository */ protected $channelRepository; /** * Create a new controller instance. * - * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository - * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository - * @param \Webkul\Core\Repositories\ChannelRepository $channelRepository + * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository + * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository + * @param \Webkul\Core\Repositories\ChannelRepository $channelRepository */ public function __construct( CustomerRepository $customerRepository, @@ -136,8 +130,7 @@ class CustomerController extends Controller /** * Show the form for editing the specified resource. * - * @param int $id - * + * @param int $id * @return \Illuminate\View\View */ public function edit($id) @@ -154,8 +147,7 @@ class CustomerController extends Controller /** * Update the specified resource in storage. * - * @param int $id - * + * @param int $id * @return \Illuminate\Http\Response */ public function update($id) @@ -182,8 +174,7 @@ class CustomerController extends Controller /** * Remove the specified resource from storage. * - * @param int $id - * + * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) @@ -206,6 +197,7 @@ class CustomerController extends Controller /** * To load the note taking screen for the customers * + * @param int $id * @return \Illuminate\View\View */ public function createNote($id) @@ -218,7 +210,7 @@ class CustomerController extends Controller /** * To store the response of the note in storage * - * @return redirect + * @return \Illuminate\Http\Response */ public function storeNote() { @@ -228,9 +220,7 @@ class CustomerController extends Controller $customer = $this->customerRepository->find(request()->input('_customer')); - $noteTaken = $customer->update([ - 'notes' => request()->input('notes'), - ]); + $noteTaken = $customer->update(['notes' => request()->input('notes')]); if ($noteTaken) { session()->flash('success', 'Note taken'); @@ -244,7 +234,7 @@ class CustomerController extends Controller /** * To mass update the customer * - * @return redirect + * @return \Illuminate\Http\Response */ public function massUpdate() { @@ -254,9 +244,7 @@ class CustomerController extends Controller foreach ($customerIds as $customerId) { $customer = $this->customerRepository->find($customerId); - $customer->update([ - 'status' => $updateOption, - ]); + $customer->update(['status' => $updateOption]); } session()->flash('success', trans('admin::app.customers.customers.mass-update-success')); @@ -267,16 +255,14 @@ class CustomerController extends Controller /** * To mass delete the customer * - * @return redirect + * @return \Illuminate\Http\Response */ public function massDestroy() { $customerIds = explode(',', request()->input('indexes')); foreach ($customerIds as $customerId) { - $this->customerRepository->deleteWhere([ - 'id' => $customerId, - ]); + $this->customerRepository->deleteWhere(['id' => $customerId]); } session()->flash('success', trans('admin::app.customers.customers.mass-destroy-success')); diff --git a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php index f4b4499bf..45adba153 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Customer/CustomerGroupController.php @@ -5,12 +5,6 @@ namespace Webkul\Admin\Http\Controllers\Customer; use Webkul\Admin\Http\Controllers\Controller; use Webkul\Customer\Repositories\CustomerGroupRepository; -/** - * Customer Group controlller - * - * @author Rahul Shukla - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class CustomerGroupController extends Controller { /** @@ -23,14 +17,14 @@ class CustomerGroupController extends Controller /** * CustomerGroupRepository object * - * @var array + * @var \Webkul\Customer\Repositories\CustomerGroupRepository */ protected $customerGroupRepository; /** * Create a new controller instance. * - * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository; + * @param \Webkul\Customer\Repositories\CustomerGroupRepository $customerGroupRepository; * @return void */ public function __construct(CustomerGroupRepository $customerGroupRepository) @@ -130,7 +124,7 @@ class CustomerGroupController extends Controller if ($customerGroup->is_user_defined == 0) { session()->flash('warning', trans('admin::app.customers.customers.group-default')); - } else if (count($customerGroup->customer) > 0) { + } elseif (count($customerGroup->customer) > 0) { session()->flash('warning', trans('admin::app.response.customer-associate', ['name' => 'Customer Group'])); } else { try { diff --git a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php index 08a81d355..70717e83c 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php @@ -9,84 +9,78 @@ use Webkul\Sales\Repositories\OrderItemRepository; use Webkul\Customer\Repositories\CustomerRepository; use Webkul\Product\Repositories\ProductInventoryRepository; -/** - * Dashboard controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class DashboardController extends Controller { /** * Display a listing of the resource. * - * @return \Illuminate\Http\Response + * @var array */ protected $_config; /** * OrderRepository object * - * @var Object + * @var \Webkul\Sales\Repositories\OrderRepository */ protected $orderRepository; /** * OrderItemRepository object * - * @var Object + * @var \Webkul\Sales\Repositories\OrderItemRepository */ protected $orderItemRepository; /** * CustomerRepository object * - * @var Object + * @var \Webkul\Customer\Repositories\CustomerRepository */ protected $customerRepository; /** * ProductInventoryRepository object * - * @var Object + * @var \Webkul\Product\Repositories\ProductInventoryRepository */ protected $productInventoryRepository; /** * string object * - * @var Object + * @var \Illuminate\Support\Carbon */ protected $startDate; /** * string object * - * @var Object + * @var \Illuminate\Support\Carbon */ protected $lastStartDate; /** * string object * - * @var Object + * @var \Illuminate\Support\Carbon */ protected $endDate; /** * string object * - * @var Object + * @var \Illuminate\Support\Carbon */ protected $lastEndDate; /** * Create a new controller instance. * - * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository - * @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository - * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository - * @param \Webkul\Product\Repositories\ProductInventoryRepository $productInventoryRepository + * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository + * @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository + * @param \Webkul\Customer\Repositories\CustomerRepository $customerRepository + * @param \Webkul\Product\Repositories\ProductInventoryRepository $productInventoryRepository * @return void */ public function __construct( @@ -112,12 +106,15 @@ class DashboardController extends Controller /** * Returns percentage difference * - * @return integer + * @param int $previous + * @param int $current + * @return int */ public function getPercentageChange($previous, $current) { - if (! $previous) + if (! $previous) { return $current ? 100 : 0; + } return ($current - $previous) / $previous * 100; } @@ -132,30 +129,30 @@ class DashboardController extends Controller $this->setStartEndDate(); $statistics = [ - 'total_customers' => [ + 'total_customers' => [ 'previous' => $previous = $this->getCustomersBetweenDates($this->lastStartDate, $this->lastEndDate)->count(), - 'current' => $current = $this->getCustomersBetweenDates($this->startDate, $this->endDate)->count(), - 'progress' => $this->getPercentageChange($previous, $current) + 'current' => $current = $this->getCustomersBetweenDates($this->startDate, $this->endDate)->count(), + 'progress' => $this->getPercentageChange($previous, $current), ], - 'total_orders' => [ + 'total_orders' => [ 'previous' => $previous = $this->previousOrders()->count(), - 'current' => $current = $this->currentOrders()->count(), - 'progress' => $this->getPercentageChange($previous, $current) + 'current' => $current = $this->currentOrders()->count(), + 'progress' => $this->getPercentageChange($previous, $current), ], - 'total_sales' => [ + 'total_sales' => [ 'previous' => $previous = $this->previousOrders()->sum('base_grand_total_invoiced') - $this->previousOrders()->sum('base_grand_total_refunded'), - 'current' => $current = $this->currentOrders()->sum('base_grand_total_invoiced') - $this->currentOrders()->sum('base_grand_total_refunded'), - 'progress' => $this->getPercentageChange($previous, $current) + 'current' => $current = $this->currentOrders()->sum('base_grand_total_invoiced') - $this->currentOrders()->sum('base_grand_total_refunded'), + 'progress' => $this->getPercentageChange($previous, $current), ], - 'avg_sales' => [ + 'avg_sales' => [ 'previous' => $previous = $this->previousOrders()->avg('base_grand_total_invoiced') - $this->previousOrders()->avg('base_grand_total_refunded'), - 'current' => $current = $this->currentOrders()->avg('base_grand_total_invoiced') - $this->currentOrders()->avg('base_grand_total_refunded'), - 'progress' => $this->getPercentageChange($previous, $current) + 'current' => $current = $this->currentOrders()->avg('base_grand_total_invoiced') - $this->currentOrders()->avg('base_grand_total_refunded'), + 'progress' => $this->getPercentageChange($previous, $current), ], - 'top_selling_categories' => $this->getTopSellingCategories(), - 'top_selling_products' => $this->getTopSellingProducts(), + 'top_selling_categories' => $this->getTopSellingCategories(), + 'top_selling_products' => $this->getTopSellingProducts(), 'customer_with_most_sales' => $this->getCustomerWithMostSales(), - 'stock_threshold' => $this->getStockThreshold(), + 'stock_threshold' => $this->getStockThreshold(), ]; foreach (core()->getTimeInterval($this->startDate, $this->endDate) as $interval) { @@ -173,80 +170,81 @@ class DashboardController extends Controller /** * Returns the list of top selling categories * - * @return Collection + * @return \Illuminate\Support\Collection */ public function getTopSellingCategories() { return $this->orderItemRepository->getModel() - ->leftJoin('products', 'order_items.product_id', 'products.id') - ->leftJoin('product_categories', 'products.id', 'product_categories.product_id') - ->leftJoin('categories', 'product_categories.category_id', 'categories.id') - ->leftJoin('category_translations', 'categories.id', 'category_translations.category_id') - ->where('category_translations.locale', app()->getLocale()) - ->where('order_items.created_at', '>=', $this->startDate) - ->where('order_items.created_at', '<=', $this->endDate) - ->addSelect(DB::raw('SUM(qty_invoiced - qty_refunded) as total_qty_invoiced')) - ->addSelect(DB::raw('COUNT(' . DB::getTablePrefix() . 'products.id) as total_products')) - ->addSelect('order_items.id', 'categories.id as category_id', 'category_translations.name') - ->groupBy('categories.id') - ->havingRaw('SUM(qty_invoiced - qty_refunded) > 0') - ->orderBy('total_qty_invoiced', 'DESC') - ->limit(5) - ->get(); + ->leftJoin('products', 'order_items.product_id', 'products.id') + ->leftJoin('product_categories', 'products.id', 'product_categories.product_id') + ->leftJoin('categories', 'product_categories.category_id', 'categories.id') + ->leftJoin('category_translations', 'categories.id', 'category_translations.category_id') + ->where('category_translations.locale', app()->getLocale()) + ->where('order_items.created_at', '>=', $this->startDate) + ->where('order_items.created_at', '<=', $this->endDate) + ->addSelect(DB::raw('SUM(qty_invoiced - qty_refunded) as total_qty_invoiced')) + ->addSelect(DB::raw('COUNT(' . DB::getTablePrefix() . 'products.id) as total_products')) + ->addSelect('order_items.id', 'categories.id as category_id', 'category_translations.name') + ->groupBy('categories.id') + ->havingRaw('SUM(qty_invoiced - qty_refunded) > 0') + ->orderBy('total_qty_invoiced', 'DESC') + ->limit(5) + ->get(); } /** * Return stock threshold. * - * @return Collection + * @return \Illuminate\Support\Collection */ public function getStockThreshold() { return $this->productInventoryRepository->getModel() - ->leftJoin('products', 'product_inventories.product_id', 'products.id') - ->select(DB::raw('SUM(qty) as total_qty')) - ->addSelect('product_inventories.product_id') - ->groupBy('product_id') - ->orderBy('total_qty', 'ASC') - ->limit(5) - ->get(); + ->leftJoin('products', 'product_inventories.product_id', 'products.id') + ->select(DB::raw('SUM(qty) as total_qty')) + ->addSelect('product_inventories.product_id') + ->groupBy('product_id') + ->orderBy('total_qty', 'ASC') + ->limit(5) + ->get(); } /** * Returns top selling products - * @return Collection + * + * @return \Illuminate\Support\Collection */ public function getTopSellingProducts() { return $this->orderItemRepository->getModel() - ->select(DB::raw('SUM(qty_ordered) as total_qty_ordered')) - ->addSelect('id', 'product_id', 'product_type', 'name') - ->where('order_items.created_at', '>=', $this->startDate) - ->where('order_items.created_at', '<=', $this->endDate) - ->whereNull('parent_id') - ->groupBy('product_id') - ->orderBy('total_qty_ordered', 'DESC') - ->limit(5) - ->get(); + ->select(DB::raw('SUM(qty_ordered) as total_qty_ordered')) + ->addSelect('id', 'product_id', 'product_type', 'name') + ->where('order_items.created_at', '>=', $this->startDate) + ->where('order_items.created_at', '<=', $this->endDate) + ->whereNull('parent_id') + ->groupBy('product_id') + ->orderBy('total_qty_ordered', 'DESC') + ->limit(5) + ->get(); } /** * Returns top selling products * - * @return Collection + * @return \Illuminate\Support\Collection */ public function getCustomerWithMostSales() { return $this->orderRepository->getModel() - ->select(DB::raw('SUM(base_grand_total) as total_base_grand_total')) - ->addSelect(DB::raw('COUNT(id) as total_orders')) - ->addSelect('id', 'customer_id', 'customer_email', 'customer_first_name', 'customer_last_name') - ->where('orders.created_at', '>=', $this->startDate) - ->where('orders.created_at', '<=', $this->endDate) - ->groupBy('customer_email') - ->orderBy('total_base_grand_total', 'DESC') - ->limit(5) - ->get(); + ->select(DB::raw('SUM(base_grand_total) as total_base_grand_total')) + ->addSelect(DB::raw('COUNT(id) as total_orders')) + ->addSelect('id', 'customer_id', 'customer_email', 'customer_first_name', 'customer_last_name') + ->where('orders.created_at', '>=', $this->startDate) + ->where('orders.created_at', '<=', $this->endDate) + ->groupBy('customer_email') + ->orderBy('total_base_grand_total', 'DESC') + ->limit(5) + ->get(); } /** @@ -257,15 +255,16 @@ class DashboardController extends Controller public function setStartEndDate() { $this->startDate = request()->get('start') - ? Carbon::createFromTimeString(request()->get('start') . " 00:00:01") - : Carbon::createFromTimeString(Carbon::now()->subDays(30)->format('Y-m-d') . " 00:00:01"); + ? Carbon::createFromTimeString(request()->get('start') . " 00:00:01") + : Carbon::createFromTimeString(Carbon::now()->subDays(30)->format('Y-m-d') . " 00:00:01"); $this->endDate = request()->get('end') - ? Carbon::createFromTimeString(request()->get('end') . " 23:59:59") - : Carbon::now(); + ? Carbon::createFromTimeString(request()->get('end') . " 23:59:59") + : Carbon::now(); - if ($this->endDate > Carbon::now()) + if ($this->endDate > Carbon::now()) { $this->endDate = Carbon::now(); + } $this->lastStartDate = clone $this->startDate; $this->lastEndDate = clone $this->startDate; @@ -277,7 +276,7 @@ class DashboardController extends Controller /** * Returns previous order query * - * @return mixed + * @return Illuminate\Database\Query\Builder */ private function previousOrders() { @@ -287,7 +286,7 @@ class DashboardController extends Controller /** * Returns current order query * - * @return mixed + * @return Illuminate\Database\Query\Builder */ private function currentOrders() { @@ -297,7 +296,9 @@ class DashboardController extends Controller /** * Returns orders between two dates * - * @return mixed + * @param \Illuminate\Support\Carbon $start + * @param \Illuminate\Support\Carbon $end + * @return Illuminate\Database\Query\Builder */ private function getOrdersBetweenDate($start, $end) { @@ -309,7 +310,9 @@ class DashboardController extends Controller /** * Returns customers between two dates * - * @return mixed + * @param \Illuminate\Support\Carbon $start + * @param \Illuminate\Support\Carbon $end + * @return Illuminate\Database\Query\Builder */ private function getCustomersBetweenDates($start, $end) { diff --git a/packages/Webkul/Admin/src/Http/Controllers/Development/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/Development/DashboardController.php index 89dbecf9a..639369332 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Development/DashboardController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Development/DashboardController.php @@ -4,12 +4,6 @@ namespace Webkul\Admin\Http\Controllers\Development; use Webkul\Admin\Http\Controllers\Controller; -/** - * Dashboard controller - * - * @author Alexey Khachatryan - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class DashboardController extends Controller { /** diff --git a/packages/Webkul/Admin/src/Http/Controllers/ExportController.php b/packages/Webkul/Admin/src/Http/Controllers/ExportController.php index 1267d40b2..911c1e6f0 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/ExportController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/ExportController.php @@ -5,21 +5,23 @@ namespace Webkul\Admin\Http\Controllers; use Webkul\Admin\Exports\DataGridExport; use Excel; -/** - * Export controlller - * - * @author Rahul Shukla - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ExportController extends Controller { protected $exportableGrids = [ - 'OrderDataGrid', 'OrderInvoicesDataGrid', 'OrderShipmentsDataGrid', 'OrderRefundDataGrid', 'CustomerDataGrid', 'TaxRateDataGrid', 'ProductDataGrid', 'CMSPageDataGrid' + 'OrderDataGrid', + 'OrderInvoicesDataGrid', + 'OrderShipmentsDataGrid', + 'OrderRefundDataGrid', + 'CustomerDataGrid', + 'TaxRateDataGrid', + 'ProductDataGrid', + 'CMSPageDataGrid', ]; /** * Create a new controller instance. * + * @return void */ public function __construct() { @@ -38,6 +40,7 @@ class ExportController extends Controller $format = $criteria['format']; $gridName = explode('\\', $criteria['gridName']); + $path = '\Webkul\Admin\DataGrids'.'\\'.last($gridName); $proceed = false; @@ -53,9 +56,10 @@ class ExportController extends Controller } $gridInstance = new $path; + $records = $gridInstance->export(); - if (count($records) == 0) { + if (! count($records)) { session()->flash('warning', trans('admin::app.export.no-records')); return redirect()->back(); diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/InvoiceController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/InvoiceController.php index ebda162a7..3931fc268 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/InvoiceController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/InvoiceController.php @@ -7,12 +7,6 @@ use Webkul\Sales\Repositories\OrderRepository; use Webkul\Sales\Repositories\InvoiceRepository; use PDF; -/** - * Sales Invoice controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class InvoiceController extends Controller { /** @@ -25,22 +19,22 @@ class InvoiceController extends Controller /** * OrderRepository object * - * @var array + * @var \Webkul\Sales\Repositories\OrderRepository */ protected $orderRepository; /** * InvoiceRepository object * - * @var array + * @var \Webkul\Sales\Repositories\InvoiceRepository */ protected $invoiceRepository; /** * Create a new controller instance. * - * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository - * @param \Webkul\Sales\Repositories\InvoiceRepository $invoiceRepository + * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository + * @param \Webkul\Sales\Repositories\InvoiceRepository $invoiceRepository * @return void */ public function __construct( @@ -70,7 +64,7 @@ class InvoiceController extends Controller /** * Show the form for creating a new resource. * - * @param int $orderId + * @param int $orderId * @return \Illuminate\View\View */ public function create($orderId) @@ -83,7 +77,7 @@ class InvoiceController extends Controller /** * Store a newly created resource in storage. * - * @param int $orderId + * @param int $orderId * @return \Illuminate\Http\Response */ public function store($orderId) @@ -103,6 +97,7 @@ class InvoiceController extends Controller $data = request()->all(); $haveProductToInvoice = false; + foreach ($data['invoice']['items'] as $itemId => $qty) { if ($qty) { $haveProductToInvoice = true; diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/OrderController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/OrderController.php index 19906800e..01b0e9142 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/OrderController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/OrderController.php @@ -5,12 +5,6 @@ namespace Webkul\Admin\Http\Controllers\Sales; use Webkul\Admin\Http\Controllers\Controller; use Webkul\Sales\Repositories\OrderRepository; -/** - * Sales Order controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class OrderController extends Controller { /** @@ -23,14 +17,14 @@ class OrderController extends Controller /** * OrderRepository object * - * @var array + * @var \Webkul\Sales\Repositories\OrderRepository */ protected $orderRepository; /** * Create a new controller instance. * - * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository + * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository * @return void */ public function __construct(OrderRepository $orderRepository) @@ -40,7 +34,6 @@ class OrderController extends Controller $this->_config = request('_config'); $this->orderRepository = $orderRepository; - } /** diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php index 47a891a25..48a23125b 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/RefundController.php @@ -7,12 +7,6 @@ use Webkul\Sales\Repositories\OrderRepository; use Webkul\Sales\Repositories\OrderItemRepository; use Webkul\Sales\Repositories\RefundRepository; -/** - * Sales Refund controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class RefundController extends Controller { /** @@ -25,30 +19,30 @@ class RefundController extends Controller /** * OrderRepository object * - * @var Object + * @var \Webkul\Sales\Repositories\OrderRepository */ protected $orderRepository; /** * OrderItemRepository object * - * @var Object + * @var \Webkul\Sales\Repositories\OrderItemRepository */ protected $orderItemRepository; /** * RefundRepository object * - * @var Object + * @var \Webkul\Sales\Repositories\RefundRepository */ protected $refundRepository; /** * Create a new controller instance. * - * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository - * @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository - * @param \Webkul\Sales\Repositories\RefundRepository $refundRepository + * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository + * @param \Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository + * @param \Webkul\Sales\Repositories\RefundRepository $refundRepository * @return void */ public function __construct( @@ -81,7 +75,7 @@ class RefundController extends Controller /** * Show the form for creating a new resource. * - * @param int $orderId + * @param int $orderId * @return \Illuminate\Http\View */ public function create($orderId) @@ -94,7 +88,7 @@ class RefundController extends Controller /** * Store a newly created resource in storage. * - * @param int $orderId + * @param int $orderId * @return \Illuminate\Http\Response */ public function store($orderId) @@ -108,7 +102,7 @@ class RefundController extends Controller } $this->validate(request(), [ - 'refund.items.*' => 'required|numeric|min:0' + 'refund.items.*' => 'required|numeric|min:0', ]); $data = request()->all(); @@ -141,15 +135,16 @@ class RefundController extends Controller /** * Store a newly created resource in storage. * - * @param int $orderId + * @param int $orderId * @return \Illuminate\Http\JsonResponse */ public function updateQty($orderId) { $data = $this->refundRepository->getOrderItemsRefundSummary(request()->all(), $orderId); - if (! $data) + if (! $data) { return response(''); + } return response()->json($data); } @@ -157,7 +152,7 @@ class RefundController extends Controller /** * Show the view for the specified resource. * - * @param int $id + * @param int $id * @return \Illuminate\Http\View */ public function view($id) diff --git a/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php b/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php index 059ce1ae7..42239458b 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/Sales/ShipmentController.php @@ -7,12 +7,6 @@ use Webkul\Sales\Repositories\OrderRepository; use Webkul\Sales\Repositories\OrderItemRepository; use Webkul\Sales\Repositories\ShipmentRepository; -/** - * Sales Shipment controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class ShipmentController extends Controller { /** @@ -25,30 +19,30 @@ class ShipmentController extends Controller /** * OrderRepository object * - * @var mixed + * @var \Webkul\Sales\Repositories\OrderRepository */ protected $orderRepository; /** * OrderItemRepository object * - * @var mixed + * @var \Webkul\Sales\Repositories\OrderItemRepository */ protected $orderItemRepository; /** * ShipmentRepository object * - * @var mixed + * @var \Webkul\Sales\Repositories\ShipmentRepository */ protected $shipmentRepository; /** * Create a new controller instance. * - * @param \Webkul\Sales\Repositories\ShipmentRepository $shipmentRepository - * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository - * @param \Webkul\Sales\Repositories\OrderitemRepository $orderItemRepository + * @param \Webkul\Sales\Repositories\ShipmentRepository $shipmentRepository + * @param \Webkul\Sales\Repositories\OrderRepository $orderRepository + * @param \Webkul\Sales\Repositories\OrderitemRepository $orderItemRepository * @return void */ public function __construct( @@ -81,7 +75,7 @@ class ShipmentController extends Controller /** * Show the form for creating a new resource. * - * @param int $orderId + * @param int $orderId * @return \Illuminate\View\View */ public function create($orderId) @@ -100,7 +94,7 @@ class ShipmentController extends Controller /** * Store a newly created resource in storage. * - * @param int $orderId + * @param int $orderId * @return \Illuminate\Http\Response */ public function store($orderId) @@ -115,9 +109,9 @@ class ShipmentController extends Controller $this->validate(request(), [ 'shipment.carrier_title' => 'required', - 'shipment.track_number' => 'required', - 'shipment.source' => 'required', - 'shipment.items.*.*' => 'required|numeric|min:0', + 'shipment.track_number' => 'required', + 'shipment.source' => 'required', + 'shipment.items.*.*' => 'required|numeric|min:0', ]); $data = request()->all(); @@ -138,13 +132,14 @@ class ShipmentController extends Controller /** * Checks if requested quantity available or not * - * @param array $data - * @return boolean + * @param array $data + * @return bool */ public function isInventoryValidate(&$data) { - if (! isset($data['shipment']['items'])) + if (! isset($data['shipment']['items'])) { return ; + } $valid = false; @@ -154,13 +149,15 @@ class ShipmentController extends Controller if ($qty = $inventorySource[$inventorySourceId]) { $orderItem = $this->orderItemRepository->find($itemId); - if ($orderItem->qty_to_ship < $qty) + if ($orderItem->qty_to_ship < $qty) { return false; + } if ($orderItem->getTypeInstance()->isComposite()) { foreach ($orderItem->children as $child) { - if (! $child->qty_ordered) + if (! $child->qty_ordered) { continue; + } $finalQty = ($child->qty_ordered / $orderItem->qty_ordered) * $qty; @@ -168,16 +165,18 @@ class ShipmentController extends Controller ->where('inventory_source_id', $inventorySourceId) ->sum('qty'); - if ($child->qty_to_ship < $finalQty || $availableQty < $finalQty) + if ($child->qty_to_ship < $finalQty || $availableQty < $finalQty) { return false; + } } } else { $availableQty = $orderItem->product->inventories() ->where('inventory_source_id', $inventorySourceId) ->sum('qty'); - if ($orderItem->qty_to_ship < $qty || $availableQty < $qty) + if ($orderItem->qty_to_ship < $qty || $availableQty < $qty) { return false; + } } $valid = true; diff --git a/packages/Webkul/Admin/src/Http/Requests/ConfigurationForm.php b/packages/Webkul/Admin/src/Http/Requests/ConfigurationForm.php index 88063814c..4611ad6b5 100644 --- a/packages/Webkul/Admin/src/Http/Requests/ConfigurationForm.php +++ b/packages/Webkul/Admin/src/Http/Requests/ConfigurationForm.php @@ -26,16 +26,11 @@ class ConfigurationForm extends FormRequest { $this->rules = []; - // if (request()->has('sales.orderSettings.order_number')) { - // $this->rules = [ - // 'sales.orderSettings.order_number.order_number_prefix' => 'required|regex:/^[a-zA-Z0-9$%^&*@]+$/u', - // 'sales.orderSettings.order_number.order_number_suffix' => 'required|regex:/^[a-zA-Z0-9$%^&*@]+$/u', - // ]; - // } - - if (request()->has('general.design.admin_logo.logo_image') && ! request()->input('general.design.admin_logo.logo_image.delete')) { + if (request()->has('general.design.admin_logo.logo_image') + && ! request()->input('general.design.admin_logo.logo_image.delete') + ) { $this->rules = [ - 'general.design.admin_logo.logo_image' => 'required|mimes:jpeg,bmp,png,jpg' + 'general.design.admin_logo.logo_image' => 'required|mimes:jpeg,bmp,png,jpg', ]; } @@ -46,13 +41,11 @@ class ConfigurationForm extends FormRequest * Get the error messages for the defined validation rules. * * @return array - */ + */ public function messages() { return [ - // 'sales.orderSettings.order_number.order_number_prefix.regex' => 'Invalid format. Can not use #.', - // 'sales.orderSettings.order_number.order_number_suffix.regex' => 'Invalid format. Can not use #.', - 'general.design.admin_logo.logo_image.mimes' => 'Invalid file format. Use only jpeg, bmp, png, jpg.' + 'general.design.admin_logo.logo_image.mimes' => 'Invalid file format. Use only jpeg, bmp, png, jpg.', ]; } } diff --git a/packages/Webkul/Admin/src/Imports/DataGridImport.php b/packages/Webkul/Admin/src/Imports/DataGridImport.php index 07ed1b7b7..76c6b35e6 100644 --- a/packages/Webkul/Admin/src/Imports/DataGridImport.php +++ b/packages/Webkul/Admin/src/Imports/DataGridImport.php @@ -7,20 +7,12 @@ use Maatwebsite\Excel\Concerns\ToCollection; use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\Importable; - -/** - * DataGridImport class - * - * @author Rahul Shukla - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) -*/ - class DataGridImport implements ToCollection, WithHeadingRow { use Importable; /** - * @param array $row + * @param Illuminate\Support\Collection $row * @return void */ public function collection(Collection $rows) diff --git a/packages/Webkul/Admin/src/Listeners/Order.php b/packages/Webkul/Admin/src/Listeners/Order.php index c6b7e7947..41385ddab 100755 --- a/packages/Webkul/Admin/src/Listeners/Order.php +++ b/packages/Webkul/Admin/src/Listeners/Order.php @@ -11,19 +11,14 @@ use Webkul\Admin\Mail\NewInventorySourceNotification; use Webkul\Admin\Mail\CancelOrderNotification; use Webkul\Admin\Mail\NewRefundNotification; -/** - * Order event handler - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class Order { /** - * @param mixed $order - * * Send new order Mail to the customer and admin + * + * @param \Webkul\Sales\Contracts\Order $order + * @return void */ public function sendNewOrderMail($order) { @@ -43,9 +38,10 @@ class Order } /** - * @param mixed $invoice - * * Send new invoice mail to the customer + * + * @param \Webkul\Sales\Contracts\Invoice $invoice + * @return void */ public function sendNewInvoiceMail($invoice) { @@ -64,9 +60,10 @@ class Order } /** - * @param mixed $refund - * * Send new refund mail to the customer + * + * @param \Webkul\Sales\Contracts\Refund $refund + * @return void */ public function sendNewRefundMail($refund) { @@ -81,9 +78,10 @@ class Order } /** - * @param mixed $shipment - * * Send new shipment mail to the customer + * + * @param \Webkul\Sales\Contracts\Shipment $refund + * @return void */ public function sendNewShipmentMail($shipment) { @@ -107,8 +105,8 @@ class Order } /** - * @param mixed $order - * + * @param \Webkul\Sales\Contracts\Order $order + * @return void */ public function sendCancelOrderMail($order) { diff --git a/packages/Webkul/Admin/src/Mail/CancelOrderNotification.php b/packages/Webkul/Admin/src/Mail/CancelOrderNotification.php index b13a93b58..b020bba9f 100644 --- a/packages/Webkul/Admin/src/Mail/CancelOrderNotification.php +++ b/packages/Webkul/Admin/src/Mail/CancelOrderNotification.php @@ -11,11 +11,15 @@ class CancelOrderNotification extends Mailable { use Queueable, SerializesModels; - /* - * @var Order - * */ + /** + * @var \Webkul\Sales\Contracts\Order + */ public $order; + /** + * @param \Webkul\Sales\Contracts\Order $order + * @return void + */ public function __construct($order) { $this->order = $order; @@ -24,7 +28,7 @@ class CancelOrderNotification extends Mailable public function build() { return $this->to($this->order->customer_email, $this->order->customer_full_name) - ->subject(trans('shop::app.mail.order.cancel.subject')) - ->view('shop::emails.sales.order-cancel'); + ->subject(trans('shop::app.mail.order.cancel.subject')) + ->view('shop::emails.sales.order-cancel'); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Mail/NewAdminNotification.php b/packages/Webkul/Admin/src/Mail/NewAdminNotification.php index b31a4ab1c..fd1426030 100644 --- a/packages/Webkul/Admin/src/Mail/NewAdminNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewAdminNotification.php @@ -7,12 +7,6 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -/** - * New Admin Mail class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class NewAdminNotification extends Mailable { use Queueable, SerializesModels; @@ -20,14 +14,14 @@ class NewAdminNotification extends Mailable /** * The order instance. * - * @var Order + * @var \Webkul\Sales\Contracts\Order */ public $order; - /** * Create a new message instance. - * + * + * @param \Webkul\Sales\Contracts\Order $order * @return void */ public function __construct($order) @@ -43,7 +37,7 @@ class NewAdminNotification extends Mailable public function build() { return $this->to(config('mail.admin.address')) - ->subject(trans('shop::app.mail.order.subject')) - ->view('shop::emails.sales.new-admin-order'); + ->subject(trans('shop::app.mail.order.subject')) + ->view('shop::emails.sales.new-admin-order'); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php b/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php index 4af9308e6..c80d68399 100644 --- a/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php @@ -7,12 +7,6 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -/** - * New Admin Mail class - * - * @author Rahul Shukla - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class NewCustomerNotification extends Mailable { use Queueable, SerializesModels; @@ -20,23 +14,28 @@ class NewCustomerNotification extends Mailable /** * The customer instance. * - * @var customer + * @var \Webkul\Customer\Contracts\Customer */ public $customer; /** * The password instance. * - * @var password + * @var string */ public $password; /** * Create a new message instance. - * + * + * @param \Webkul\Customer\Contracts\Customer $order + * @param string $password * @return void */ - public function __construct($customer, $password) + public function __construct( + $customer, + $password + ) { $this->customer = $customer; @@ -51,7 +50,7 @@ class NewCustomerNotification extends Mailable public function build() { return $this->to($this->customer->email) - ->subject(trans('shop::app.mail.customer.new.subject')) - ->view('shop::emails.customer.new-customer')->with(['customer' => $this->customer, 'password' => $this->password]); + ->subject(trans('shop::app.mail.customer.new.subject')) + ->view('shop::emails.customer.new-customer')->with(['customer' => $this->customer, 'password' => $this->password]); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Mail/NewInventorySourceNotification.php b/packages/Webkul/Admin/src/Mail/NewInventorySourceNotification.php index 4ed66f352..931d55a09 100644 --- a/packages/Webkul/Admin/src/Mail/NewInventorySourceNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewInventorySourceNotification.php @@ -7,12 +7,6 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -/** - * New InventorySource Notification Mail class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class NewInventorySourceNotification extends Mailable { use Queueable, SerializesModels; @@ -20,14 +14,14 @@ class NewInventorySourceNotification extends Mailable /** * The shipment instance. * - * @var Shipment + * @var \Webkul\Customer\Contracts\Shipment */ public $shipment; /** * Create a new message instance. * - * @param mixed $shipment + * @param \Webkul\Customer\Contracts\Shipment $shipment * @return void */ public function __construct($shipment) @@ -43,10 +37,11 @@ class NewInventorySourceNotification extends Mailable public function build() { $order = $this->shipment->order; + $inventory = $this->shipment->inventory_source; return $this->to($inventory->contact_email, $inventory->name) - ->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id])) - ->view('shop::emails.sales.new-inventorysource-shipment'); + ->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id])) + ->view('shop::emails.sales.new-inventorysource-shipment'); } } diff --git a/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php b/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php index 2b9cf68e3..a8bf2fba9 100755 --- a/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php @@ -7,12 +7,6 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -/** - * New Invoice Mail class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class NewInvoiceNotification extends Mailable { use Queueable, SerializesModels; @@ -20,14 +14,14 @@ class NewInvoiceNotification extends Mailable /** * The invoice instance. * - * @var Invoice + * @param \Webkul\Customer\Contracts\Invoice $invoice */ public $invoice; /** * Create a new message instance. * - * @param mixed $invoice + * @param \Webkul\Customer\Contracts\Invoice $invoice * @return void */ public function __construct($invoice) @@ -45,7 +39,7 @@ class NewInvoiceNotification extends Mailable $order = $this->invoice->order; return $this->to($order->customer_email, $order->customer_full_name) - ->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id])) - ->view('shop::emails.sales.new-invoice'); + ->subject(trans('shop::app.mail.invoice.subject', ['order_id' => $order->increment_id])) + ->view('shop::emails.sales.new-invoice'); } } diff --git a/packages/Webkul/Admin/src/Mail/NewOrderNotification.php b/packages/Webkul/Admin/src/Mail/NewOrderNotification.php index cc1f332af..ca4b8c680 100755 --- a/packages/Webkul/Admin/src/Mail/NewOrderNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewOrderNotification.php @@ -7,12 +7,6 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -/** - * New Order Mail class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class NewOrderNotification extends Mailable { use Queueable, SerializesModels; @@ -20,13 +14,14 @@ class NewOrderNotification extends Mailable /** * The order instance. * - * @var Order + * @var \Webkul\Sales\Contracts\Order $order */ public $order; /** * Create a new message instance. * + * @param \Webkul\Sales\Contracts\Order $order * @return void */ public function __construct($order) @@ -42,7 +37,7 @@ class NewOrderNotification extends Mailable public function build() { return $this->to($this->order->customer_email, $this->order->customer_full_name) - ->subject(trans('shop::app.mail.order.subject')) - ->view('shop::emails.sales.new-order'); + ->subject(trans('shop::app.mail.order.subject')) + ->view('shop::emails.sales.new-order'); } } diff --git a/packages/Webkul/Admin/src/Mail/NewRefundNotification.php b/packages/Webkul/Admin/src/Mail/NewRefundNotification.php index 2de6230cd..3e1d04bf6 100644 --- a/packages/Webkul/Admin/src/Mail/NewRefundNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewRefundNotification.php @@ -7,12 +7,6 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -/** - * New Refund Mail class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class NewRefundNotification extends Mailable { use Queueable, SerializesModels; @@ -20,14 +14,14 @@ class NewRefundNotification extends Mailable /** * The refund instance. * - * @var Refund + * @var \Webkul\Sales\Contracts\Refund */ public $refund; /** * Create a new message instance. * - * @param mixed $refund + * @param \Webkul\Sales\Contracts\Refund $refund * @return void */ public function __construct($refund) @@ -45,7 +39,7 @@ class NewRefundNotification extends Mailable $order = $this->refund->order; return $this->to($order->customer_email, $order->customer_full_name) - ->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id])) - ->view('shop::emails.sales.new-refund'); + ->subject(trans('shop::app.mail.refund.subject', ['order_id' => $order->increment_id])) + ->view('shop::emails.sales.new-refund'); } } diff --git a/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php b/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php index 9b53c49a3..f18ab994e 100755 --- a/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php @@ -7,12 +7,6 @@ use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; use Illuminate\Contracts\Queue\ShouldQueue; -/** - * New Shipment Mail class - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class NewShipmentNotification extends Mailable { use Queueable, SerializesModels; @@ -20,14 +14,14 @@ class NewShipmentNotification extends Mailable /** * The shipment instance. * - * @var Shipment + * @var \Webkul\Sales\Contracts\Shipment */ public $shipment; /** * Create a new message instance. * - * @param mixed $shipment + * @param \Webkul\Sales\Contracts\Shipment $shipment * @return void */ public function __construct($shipment) @@ -45,7 +39,7 @@ class NewShipmentNotification extends Mailable $order = $this->shipment->order; return $this->to($order->customer_email, $order->customer_full_name) - ->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id])) - ->view('shop::emails.sales.new-shipment'); + ->subject(trans('shop::app.mail.shipment.subject', ['order_id' => $order->increment_id])) + ->view('shop::emails.sales.new-shipment'); } } diff --git a/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php b/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php index 987f84924..97f1f36ec 100755 --- a/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php +++ b/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php @@ -8,12 +8,6 @@ use Illuminate\Contracts\Debug\ExceptionHandler; use Webkul\Admin\Exceptions\Handler; use Webkul\Core\Tree; -/** - * Admin service provider - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AdminServiceProvider extends ServiceProvider { /** @@ -139,8 +133,9 @@ class AdminServiceProvider extends ServiceProvider { static $tree; - if ($tree) + if ($tree) { return $tree; + } $tree = Tree::create(); diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/accordians/grouped-products.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/accordians/grouped-products.blade.php index 8a3908f3b..20fef053c 100644 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/accordians/grouped-products.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/accordians/grouped-products.blade.php @@ -203,9 +203,9 @@ computed: { inputName: function () { if (this.groupedProduct.id) - return "links[" + this.groupedProduct.id + "]"; + return 'links[' + this.groupedProduct.id + ']'; - return "links[link_" + this.index + "]"; + return 'links[link_' + this.index + ']'; } }, diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php index 6adba4afc..c1cfcf2e1 100755 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php @@ -77,23 +77,23 @@ @foreach ($customAttributes as $attribute) code == 'guest_checkout' && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) { - continue; - } + if ($attribute->code == 'guest_checkout' && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) { + continue; + } - $validations = []; + $validations = []; - if ($attribute->is_required) { - array_push($validations, 'required'); - } + if ($attribute->is_required) { + array_push($validations, 'required'); + } - if ($attribute->type == 'price') { - array_push($validations, 'decimal'); - } + if ($attribute->type == 'price') { + array_push($validations, 'decimal'); + } - array_push($validations, $attribute->validation); + array_push($validations, $attribute->validation); - $validations = implode('|', array_filter($validations)); + $validations = implode('|', array_filter($validations)); ?> @if (view()->exists($typeView = 'admin::catalog.products.field-types.' . $attribute->type)) diff --git a/packages/Webkul/Attribute/src/Database/Factories/AttributeFactory.php b/packages/Webkul/Attribute/src/Database/Factories/AttributeFactory.php index 95a538780..507f8bcdf 100644 --- a/packages/Webkul/Attribute/src/Database/Factories/AttributeFactory.php +++ b/packages/Webkul/Attribute/src/Database/Factories/AttributeFactory.php @@ -33,21 +33,21 @@ $factory->define(Attribute::class, function (Faker $faker, array $attributes) { } return [ - 'admin_name' => $faker->word, - 'code' => $faker->word, - 'type' => array_rand($types), - 'validation' => '', - 'position' => $faker->randomDigit, - 'is_required' => false, - 'is_unique' => false, - 'value_per_locale' => false, - 'value_per_channel' => false, - 'is_filterable' => false, - 'is_configurable' => false, - 'is_user_defined' => true, + 'admin_name' => $faker->word, + 'code' => $faker->word, + 'type' => array_rand($types), + 'validation' => '', + 'position' => $faker->randomDigit, + 'is_required' => false, + 'is_unique' => false, + 'value_per_locale' => false, + 'value_per_channel' => false, + 'is_filterable' => false, + 'is_configurable' => false, + 'is_user_defined' => true, 'is_visible_on_front' => true, - 'swatch_type' => null, - 'use_in_flat' => true, + 'swatch_type' => null, + 'use_in_flat' => true, ]; }); diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php index 9926ecd3d..6f16f8f98 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php @@ -14,7 +14,13 @@ class AttributeFamilyTableSeeder extends Seeder DB::table('attribute_families')->delete(); DB::table('attribute_families')->insert([ - ['id' => '1','code' => 'default','name' => 'Default','status' => '0','is_user_defined' => '1'] + [ + 'id' => '1', + 'code' => 'default', + 'name' => 'Default', + 'status' => '0', + 'is_user_defined' => '1', + ] ]); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php index 394c5ac48..bfa7f7b95 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeGroupTableSeeder.php @@ -12,45 +12,151 @@ class AttributeGroupTableSeeder extends Seeder DB::statement('SET FOREIGN_KEY_CHECKS=0;'); DB::table('attribute_groups')->delete(); + DB::table('attribute_group_mappings')->delete(); DB::table('attribute_groups')->delete(); DB::table('attribute_groups')->insert([ - ['id' => '1','name' => 'General','position' => '1','is_user_defined' => '0','attribute_family_id' => '1'], - ['id' => '2','name' => 'Description','position' => '2','is_user_defined' => '0','attribute_family_id' => '1'], - ['id' => '3','name' => 'Meta Description','position' => '3','is_user_defined' => '0','attribute_family_id' => '1'], - ['id' => '4','name' => 'Price','position' => '4','is_user_defined' => '0','attribute_family_id' => '1'], - ['id' => '5','name' => 'Shipping','position' => '5','is_user_defined' => '0','attribute_family_id' => '1'] + [ + 'id' => '1', + 'name' => 'General', + 'position' => '1', + 'is_user_defined' => '0', + 'attribute_family_id' => '1', + ], [ + 'id' => '2', + 'name' => 'Description', + 'position' => '2', + 'is_user_defined' => '0', + 'attribute_family_id' => '1', + ], [ + 'id' => '3', + 'name' => 'Meta Description', + 'position' => '3', + 'is_user_defined' => '0', + 'attribute_family_id' => '1', + ], [ + 'id' => '4', + 'name' => 'Price', + 'position' => '4', + 'is_user_defined' => '0', + 'attribute_family_id' => '1', + ], [ + 'id' => '5', + 'name' => 'Shipping', + 'position' => '5', + 'is_user_defined' => '0', + 'attribute_family_id' => '1' + ], ]); DB::table('attribute_group_mappings')->insert([ - ['attribute_id' => '1','attribute_group_id' => '1','position' => '1'], - ['attribute_id' => '2','attribute_group_id' => '1','position' => '2'], - ['attribute_id' => '3','attribute_group_id' => '1','position' => '3'], - ['attribute_id' => '4','attribute_group_id' => '1','position' => '4'], - ['attribute_id' => '5','attribute_group_id' => '1','position' => '5'], - ['attribute_id' => '6','attribute_group_id' => '1','position' => '6'], - ['attribute_id' => '7','attribute_group_id' => '1','position' => '7'], - ['attribute_id' => '8','attribute_group_id' => '1','position' => '8'], - ['attribute_id' => '9','attribute_group_id' => '2','position' => '1'], - ['attribute_id' => '10','attribute_group_id' => '2','position' => '2'], - ['attribute_id' => '11','attribute_group_id' => '4','position' => '1'], - ['attribute_id' => '12','attribute_group_id' => '4','position' => '2'], - ['attribute_id' => '13','attribute_group_id' => '4','position' => '3'], - ['attribute_id' => '14','attribute_group_id' => '4','position' => '4'], - ['attribute_id' => '15','attribute_group_id' => '4','position' => '5'], - ['attribute_id' => '16','attribute_group_id' => '3','position' => '1'], - ['attribute_id' => '17','attribute_group_id' => '3','position' => '2'], - ['attribute_id' => '18','attribute_group_id' => '3','position' => '3'], - ['attribute_id' => '19','attribute_group_id' => '5','position' => '1'], - ['attribute_id' => '20','attribute_group_id' => '5','position' => '2'], - ['attribute_id' => '21','attribute_group_id' => '5','position' => '3'], - ['attribute_id' => '22','attribute_group_id' => '5','position' => '4'], - ['attribute_id' => '23','attribute_group_id' => '1','position' => '10'], - ['attribute_id' => '24','attribute_group_id' => '1','position' => '11'], - ['attribute_id' => '25','attribute_group_id' => '1','position' => '12'], - ['attribute_id' => '26','attribute_group_id' => '1','position' => '9'] + [ + 'attribute_id' => '1', + 'attribute_group_id' => '1', + 'position' => '1', + ], [ + 'attribute_id' => '2', + 'attribute_group_id' => '1', + 'position' => '2', + ], [ + 'attribute_id' => '3', + 'attribute_group_id' => '1', + 'position' => '3', + ], [ + 'attribute_id' => '4', + 'attribute_group_id' => '1', + 'position' => '4', + ], [ + 'attribute_id' => '5', + 'attribute_group_id' => '1', + 'position' => '5', + ], [ + 'attribute_id' => '6', + 'attribute_group_id' => '1', + 'position' => '6', + ], [ + 'attribute_id' => '7', + 'attribute_group_id' => '1', + 'position' => '7', + ], [ + 'attribute_id' => '8', + 'attribute_group_id' => '1', + 'position' => '8', + ], [ + 'attribute_id' => '9', + 'attribute_group_id' => '2', + 'position' => '1', + ], [ + 'attribute_id' => '10', + 'attribute_group_id' => '2', + 'position' => '2', + ], [ + 'attribute_id' => '11', + 'attribute_group_id' => '4', + 'position' => '1', + ], [ + 'attribute_id' => '12', + 'attribute_group_id' => '4', + 'position' => '2', + ], [ + 'attribute_id' => '13', + 'attribute_group_id' => '4', + 'position' => '3', + ], [ + 'attribute_id' => '14', + 'attribute_group_id' => '4', + 'position' => '4', + ], [ + 'attribute_id' => '15', + 'attribute_group_id' => '4', + 'position' => '5', + ], [ + 'attribute_id' => '16', + 'attribute_group_id' => '3', + 'position' => '1', + ], [ + 'attribute_id' => '17', + 'attribute_group_id' => '3', + 'position' => '2', + ], [ + 'attribute_id' => '18', + 'attribute_group_id' => '3', + 'position' => '3', + ], [ + 'attribute_id' => '19', + 'attribute_group_id' => '5', + 'position' => '1', + ], [ + 'attribute_id' => '20', + 'attribute_group_id' => '5', + 'position' => '2', + ], [ + 'attribute_id' => '21', + 'attribute_group_id' => '5', + 'position' => '3', + ], [ + 'attribute_id' => '22', + 'attribute_group_id' => '5', + 'position' => '4', + ], [ + 'attribute_id' => '23', + 'attribute_group_id' => '1', + 'position' => '10', + ], [ + 'attribute_id' => '24', + 'attribute_group_id' => '1', + 'position' => '11', + ], [ + 'attribute_id' => '25', + 'attribute_group_id' => '1', + 'position' => '12', + ], [ + 'attribute_id' => '26', + 'attribute_group_id' => '1', + 'position' => '9', + ] ]); DB::statement('SET FOREIGN_KEY_CHECKS=0;'); diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php index 5bdc0ba9e..9fcf3dbfd 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeOptionTableSeeder.php @@ -11,30 +11,105 @@ class AttributeOptionTableSeeder extends Seeder public function run() { DB::table('attribute_options')->delete(); + DB::table('attribute_option_translations')->delete(); DB::table('attribute_options')->insert([ - ['id' => '1', 'admin_name' => 'Red', 'sort_order' => '1', 'attribute_id' => '23'], - ['id' => '2', 'admin_name' => 'Green', 'sort_order' => '2', 'attribute_id' => '23'], - ['id' => '3', 'admin_name' => 'Yellow', 'sort_order' => '3', 'attribute_id' => '23'], - ['id' => '4', 'admin_name' => 'Black', 'sort_order' => '4', 'attribute_id' => '23'], - ['id' => '5', 'admin_name' => 'White', 'sort_order' => '5', 'attribute_id' => '23'], - ['id' => '6', 'admin_name' => 'S', 'sort_order' => '1', 'attribute_id' => '24'], - ['id' => '7', 'admin_name' => 'M', 'sort_order' => '2', 'attribute_id' => '24'], - ['id' => '8', 'admin_name' => 'L', 'sort_order' => '3', 'attribute_id' => '24'], - ['id' => '9', 'admin_name' => 'XL', 'sort_order' => '4', 'attribute_id' => '24'] + [ + 'id' => '1', + 'admin_name' => 'Red', + 'sort_order' => '1', + 'attribute_id' => '23', + ], [ + 'id' => '2', + 'admin_name' => 'Green', + 'sort_order' => '2', + 'attribute_id' => '23', + ], [ + 'id' => '3', + 'admin_name' => 'Yellow', + 'sort_order' => '3', + 'attribute_id' => '23', + ], [ + 'id' => '4', + 'admin_name' => 'Black', + 'sort_order' => '4', + 'attribute_id' => '23', + ], [ + 'id' => '5', + 'admin_name' => 'White', + 'sort_order' => '5', + 'attribute_id' => '23', + ], [ + 'id' => '6', + 'admin_name' => 'S', + 'sort_order' => '1', + 'attribute_id' => '24', + ], [ + 'id' => '7', + 'admin_name' => 'M', + 'sort_order' => '2', + 'attribute_id' => '24', + ], [ + 'id' => '8', + 'admin_name' => 'L', + 'sort_order' => '3', + 'attribute_id' => '24', + ], [ + 'id' => '9', + 'admin_name' => 'XL', + 'sort_order' => '4', + 'attribute_id' => '24', + ] ]); DB::table('attribute_option_translations')->insert([ - ['id' => '1', 'locale' => 'en', 'label' => 'Red', 'attribute_option_id' => '1'], - ['id' => '2', 'locale' => 'en', 'label' => 'Green', 'attribute_option_id' => '2'], - ['id' => '3', 'locale' => 'en', 'label' => 'Yellow', 'attribute_option_id' => '3'], - ['id' => '4', 'locale' => 'en', 'label' => 'Black', 'attribute_option_id' => '4'], - ['id' => '5', 'locale' => 'en', 'label' => 'White', 'attribute_option_id' => '5'], - ['id' => '6', 'locale' => 'en', 'label' => 'S', 'attribute_option_id' => '6'], - ['id' => '7', 'locale' => 'en', 'label' => 'M', 'attribute_option_id' => '7'], - ['id' => '8', 'locale' => 'en', 'label' => 'L', 'attribute_option_id' => '8'], - ['id' => '9', 'locale' => 'en', 'label' => 'XL', 'attribute_option_id' => '9'] + [ + 'id' => '1', + 'locale' => 'en', + 'label' => 'Red', + 'attribute_option_id' => '1', + ], [ + 'id' => '2', + 'locale' => 'en', + 'label' => 'Green', + 'attribute_option_id' => '2', + ], [ + 'id' => '3', + 'locale' => 'en', + 'label' => 'Yellow', + 'attribute_option_id' => '3', + ], [ + 'id' => '4', + 'locale' => 'en', + 'label' => 'Black', + 'attribute_option_id' => '4', + ], [ + 'id' => '5', + 'locale' => 'en', + 'label' => 'White', + 'attribute_option_id' => '5', + ], [ + 'id' => '6', + 'locale' => 'en', + 'label' => 'S', + 'attribute_option_id' => '6', + ], [ + 'id' => '7', + 'locale' => 'en', + 'label' => 'M', + 'attribute_option_id' => '7', + ], [ + 'id' => '8', + 'locale' => 'en', + 'label' => 'L', + 'attribute_option_id' => '8', + ], [ + 'id' => '9', + 'locale' => 'en', + 'label' => 'XL', + 'attribute_option_id' => '9', + ] ]); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php index 80735a1bd..ba618b391 100755 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php @@ -12,113 +12,641 @@ class AttributeTableSeeder extends Seeder public function run() { DB::table('attributes')->delete(); + DB::table('attribute_translations')->delete(); $now = Carbon::now(); DB::table('attributes')->insert([ - ['id' => '1','code' => 'sku','admin_name' => 'SKU','type' => 'text','validation' => NULL,'position' => '1','is_required' => '1','is_unique' => '1','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '2','code' => 'name','admin_name' => 'Name','type' => 'text','validation' => NULL,'position' => '2','is_required' => '1','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '1'], - - ['id' => '3','code' => 'url_key','admin_name' => 'URL Key','type' => 'text','validation' => NULL,'position' => '3','is_required' => '1','is_unique' => '1','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '4','code' => 'tax_category_id','admin_name' => 'Tax Category','type' => 'select','validation' => NULL,'position' => '4','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '5','code' => 'new','admin_name' => 'New','type' => 'boolean','validation' => NULL,'position' => '5','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '6','code' => 'featured','admin_name' => 'Featured','type' => 'boolean','validation' => NULL,'position' => '6','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '7','code' => 'visible_individually','admin_name' => 'Visible Individually','type' => 'boolean','validation' => NULL,'position' => '7','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','created_at' => $now, 'use_in_flat' => '1','updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '8','code' => 'status','admin_name' => 'Status','type' => 'boolean','validation' => NULL,'position' => '8','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '9','code' => 'short_description','admin_name' => 'Short Description','type' => 'textarea','validation' => NULL,'position' => '9','is_required' => '1','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0', - 'is_visible_on_front' => '0','use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '11','code' => 'price','admin_name' => 'Price','type' => 'price','validation' => 'decimal','position' => '11','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '1'], - - ['id' => '10','code' => 'description','admin_name' => 'Description','type' => 'textarea','validation' => NULL,'position' => '10','is_required' => '1','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '1'], - - ['id' => '12','code' => 'cost','admin_name' => 'Cost','type' => 'price','validation' => 'decimal','position' => '12','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '1','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '13','code' => 'special_price','admin_name' => 'Special Price','type' => 'price','validation' => 'decimal','position' => '13','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '14','code' => 'special_price_from','admin_name' => 'Special Price From','type' => 'date','validation' => NULL,'position' => '14','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0','use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '15','code' => 'special_price_to','admin_name' => 'Special Price To','type' => 'date','validation' => NULL,'position' => '15','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0', - 'use_in_flat' => '1','is_visible_on_front' => '0','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '16','code' => 'meta_title','admin_name' => 'Meta Title','type' => 'textarea','validation' => NULL,'position' => '16','is_required' => '0','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '17','code' => 'meta_keywords','admin_name' => 'Meta Keywords','type' => 'textarea','validation' => NULL,'position' => '17','is_required' => '0','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '18','code' => 'meta_description','admin_name' => 'Meta Description','type' => 'textarea','validation' => NULL,'position' => '18','is_required' => '0','is_unique' => '0','value_per_locale' => '1','value_per_channel' => '1','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '1','is_visible_on_front' => '0','use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '19','code' => 'width','admin_name' => 'Width','type' => 'text','validation' => 'decimal','position' => '19','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '1','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '20','code' => 'height','admin_name' => 'Height','type' => 'text','validation' => 'decimal','position' => '20','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '1','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '21','code' => 'depth','admin_name' => 'Depth','type' => 'text','validation' => 'decimal','position' => '21','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '1','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '22','code' => 'weight','admin_name' => 'Weight','type' => 'text','validation' => 'decimal','position' => '22','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '23','code' => 'color','admin_name' => 'Color','type' => 'select','validation' => NULL,'position' => '23','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '1','is_user_defined' => '1','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '24','code' => 'size','admin_name' => 'Size','type' => 'select','validation' => NULL,'position' => '24','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '1','is_user_defined' => '1','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '25','code' => 'brand','admin_name' => 'Brand','type' => 'select','validation' => NULL,'position' => '25','is_required' => '0','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '1','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '1', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], - - ['id' => '26','code' => 'guest_checkout','admin_name' => 'Guest Checkout','type' => 'boolean','validation' => NULL,'position' => '8','is_required' => '1','is_unique' => '0','value_per_locale' => '0','value_per_channel' => '0','is_filterable' => '0','is_configurable' => '0','is_user_defined' => '0','is_visible_on_front' => '0', - 'use_in_flat' => '1','created_at' => $now,'updated_at' => $now, 'is_comparable' => '0'], + [ + 'id' => '1', + 'code' => 'sku', + 'admin_name' => 'SKU', + 'type' => 'text', + 'validation' => NULL, + 'position' => '1', + 'is_required' => '1', + 'is_unique' => '1', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '2', + 'code' => 'name', + 'admin_name' => 'Name', + 'type' => 'text', + 'validation' => NULL, + 'position' => '2', + 'is_required' => '1', + 'is_unique' => '0', + 'value_per_locale' => '1', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '1', + ], [ + 'id' => '3', + 'code' => 'url_key', + 'admin_name' => 'URL Key', + 'type' => 'text', + 'validation' => NULL, + 'position' => '3', + 'is_required' => '1', + 'is_unique' => '1', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '4', + 'code' => 'tax_category_id', + 'admin_name' => 'Tax Category', + 'type' => 'select', + 'validation' => NULL, + 'position' => '4', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '5', + 'code' => 'new', + 'admin_name' => 'New', + 'type' => 'boolean', + 'validation' => NULL, + 'position' => '5', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '6', + 'code' => 'featured', + 'admin_name' => 'Featured', + 'type' => 'boolean', + 'validation' => NULL, + 'position' => '6', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '7', + 'code' => 'visible_individually', + 'admin_name' => 'Visible Individually', + 'type' => 'boolean', + 'validation' => NULL, + 'position' => '7', + 'is_required' => '1', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'created_at' => $now, + 'use_in_flat' => '1', + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '8', + 'code' => 'status', + 'admin_name' => 'Status', + 'type' => 'boolean', + 'validation' => NULL, + 'position' => '8', + 'is_required' => '1', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '9', + 'code' => 'short_description', + 'admin_name' => 'Short Description', + 'type' => 'textarea', + 'validation' => NULL, + 'position' => '9', + 'is_required' => '1', + 'is_unique' => '0', + 'value_per_locale' => '1', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '10', + 'code' => 'description', + 'admin_name' => 'Description', + 'type' => 'textarea', + 'validation' => NULL, + 'position' => '10', + 'is_required' => '1', + 'is_unique' => '0', + 'value_per_locale' => '1', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '1', + ], [ + 'id' => '11', + 'code' => 'price', + 'admin_name' => 'Price', + 'type' => 'price', + 'validation' => 'decimal', + 'position' => '11', + 'is_required' => '1', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '1', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '1', + ], [ + 'id' => '12', + 'code' => 'cost', + 'admin_name' => 'Cost', + 'type' => 'price', + 'validation' => 'decimal', + 'position' => '12', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '1', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '13', + 'code' => 'special_price', + 'admin_name' => 'Special Price', + 'type' => 'price', + 'validation' => 'decimal', + 'position' => '13', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '14', + 'code' => 'special_price_from', + 'admin_name' => 'Special Price From', + 'type' => 'date', + 'validation' => NULL, + 'position' => '14', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '15', + 'code' => 'special_price_to', + 'admin_name' => 'Special Price To', + 'type' => 'date', + 'validation' => NULL, + 'position' => '15', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'use_in_flat' => '1', + 'is_visible_on_front' => '0', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '16', + 'code' => 'meta_title', + 'admin_name' => 'Meta Title', + 'type' => 'textarea', + 'validation' => NULL, + 'position' => '16', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '1', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '17', + 'code' => 'meta_keywords', + 'admin_name' => 'Meta Keywords', + 'type' => 'textarea', + 'validation' => NULL, + 'position' => '17', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '1', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '18', + 'code' => 'meta_description', + 'admin_name' => 'Meta Description', + 'type' => 'textarea', + 'validation' => NULL, + 'position' => '18', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '1', + 'value_per_channel' => '1', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '1', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '19', + 'code' => 'width', + 'admin_name' => 'Width', + 'type' => 'text', + 'validation' => 'decimal', + 'position' => '19', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '1', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '20', + 'code' => 'height', + 'admin_name' => 'Height', + 'type' => 'text', + 'validation' => 'decimal', + 'position' => '20', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '1', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '21', + 'code' => 'depth', + 'admin_name' => 'Depth', + 'type' => 'text', + 'validation' => 'decimal', + 'position' => '21', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '1', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '22', + 'code' => 'weight', + 'admin_name' => 'Weight', + 'type' => 'text', + 'validation' => 'decimal', + 'position' => '22', + 'is_required' => '1', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '23', + 'code' => 'color', + 'admin_name' => 'Color', + 'type' => 'select', + 'validation' => NULL, + 'position' => '23', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '1', + 'is_configurable' => '1', + 'is_user_defined' => '1', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '24', + 'code' => 'size', + 'admin_name' => 'Size', + 'type' => 'select', + 'validation' => NULL, + 'position' => '24', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '1', + 'is_configurable' => '1', + 'is_user_defined' => '1', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '25', + 'code' => 'brand', + 'admin_name' => 'Brand', + 'type' => 'select', + 'validation' => NULL, + 'position' => '25', + 'is_required' => '0', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '1', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '1', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ], [ + 'id' => '26', + 'code' => 'guest_checkout', + 'admin_name' => 'Guest Checkout', + 'type' => 'boolean', + 'validation' => NULL, + 'position' => '8', + 'is_required' => '1', + 'is_unique' => '0', + 'value_per_locale' => '0', + 'value_per_channel' => '0', + 'is_filterable' => '0', + 'is_configurable' => '0', + 'is_user_defined' => '0', + 'is_visible_on_front' => '0', + 'use_in_flat' => '1', + 'created_at' => $now, + 'updated_at' => $now, + 'is_comparable' => '0', + ] ]); - DB::table('attribute_translations')->insert([ - ['id' => '1','locale' => 'en','name' => 'SKU','attribute_id' => '1'], - ['id' => '2','locale' => 'en','name' => 'Name','attribute_id' => '2'], - ['id' => '3','locale' => 'en','name' => 'URL Key','attribute_id' => '3'], - ['id' => '4','locale' => 'en','name' => 'Tax Category','attribute_id' => '4'], - ['id' => '5','locale' => 'en','name' => 'New','attribute_id' => '5'], - ['id' => '6','locale' => 'en','name' => 'Featured','attribute_id' => '6'], - ['id' => '7','locale' => 'en','name' => 'Visible Individually','attribute_id' => '7'], - ['id' => '8','locale' => 'en','name' => 'Status','attribute_id' => '8'], - ['id' => '9','locale' => 'en','name' => 'Short Description','attribute_id' => '9'], - ['id' => '10','locale' => 'en','name' => 'Description','attribute_id' => '10'], - ['id' => '11','locale' => 'en','name' => 'Price','attribute_id' => '11'], - ['id' => '12','locale' => 'en','name' => 'Cost','attribute_id' => '12'], - ['id' => '13','locale' => 'en','name' => 'Special Price','attribute_id' => '13'], - ['id' => '14','locale' => 'en','name' => 'Special Price From','attribute_id' => '14'], - ['id' => '15','locale' => 'en','name' => 'Special Price To','attribute_id' => '15'], - ['id' => '16','locale' => 'en','name' => 'Meta Description','attribute_id' => '16'], - ['id' => '17','locale' => 'en','name' => 'Meta Keywords','attribute_id' => '17'], - ['id' => '18','locale' => 'en','name' => 'Meta Description','attribute_id' => '18'], - ['id' => '19','locale' => 'en','name' => 'Width','attribute_id' => '19'], - ['id' => '20','locale' => 'en','name' => 'Height','attribute_id' => '20'], - ['id' => '21','locale' => 'en','name' => 'Depth','attribute_id' => '21'], - ['id' => '22','locale' => 'en','name' => 'Weight','attribute_id' => '22'], - ['id' => '23','locale' => 'en','name' => 'Color','attribute_id' => '23'], - ['id' => '24','locale' => 'en','name' => 'Size','attribute_id' => '24'], - ['id' => '25','locale' => 'en','name' => 'Brand','attribute_id' => '25'], - ['id' => '26','locale' => 'en','name' => 'Allow Guest Checkout','attribute_id' => '26'] + [ + 'id' => '1', + 'locale' => 'en', + 'name' => 'SKU', + 'attribute_id' => '1', + ], [ + 'id' => '2', + 'locale' => 'en', + 'name' => 'Name', + 'attribute_id' => '2', + ], [ + 'id' => '3', + 'locale' => 'en', + 'name' => 'URL Key', + 'attribute_id' => '3', + ], [ + 'id' => '4', + 'locale' => 'en', + 'name' => 'Tax Category', + 'attribute_id' => '4', + ], [ + 'id' => '5', + 'locale' => 'en', + 'name' => 'New', + 'attribute_id' => '5', + ], [ + 'id' => '6', + 'locale' => 'en', + 'name' => 'Featured', + 'attribute_id' => '6', + ], [ + 'id' => '7', + 'locale' => 'en', + 'name' => 'Visible Individually', + 'attribute_id' => '7', + ], [ + 'id' => '8', + 'locale' => 'en', + 'name' => 'Status', + 'attribute_id' => '8', + ], [ + 'id' => '9', + 'locale' => 'en', + 'name' => 'Short Description', + 'attribute_id' => '9', + ], [ + 'id' => '10', + 'locale' => 'en', + 'name' => 'Description', + 'attribute_id' => '10', + ], [ + 'id' => '11', + 'locale' => 'en', + 'name' => 'Price', + 'attribute_id' => '11', + ], [ + 'id' => '12', + 'locale' => 'en', + 'name' => 'Cost', + 'attribute_id' => '12', + ], [ + 'id' => '13', + 'locale' => 'en', + 'name' => 'Special Price', + 'attribute_id' => '13', + ], [ + 'id' => '14', + 'locale' => 'en', + 'name' => 'Special Price From', + 'attribute_id' => '14', + ], [ + 'id' => '15', + 'locale' => 'en', + 'name' => 'Special Price To', + 'attribute_id' => '15', + ], [ + 'id' => '16', + 'locale' => 'en', + 'name' => 'Meta Description', + 'attribute_id' => '16', + ], [ + 'id' => '17', + 'locale' => 'en', + 'name' => 'Meta Keywords', + 'attribute_id' => '17', + ], [ + 'id' => '18', + 'locale' => 'en', + 'name' => 'Meta Description', + 'attribute_id' => '18', + ], [ + 'id' => '19', + 'locale' => 'en', + 'name' => 'Width', + 'attribute_id' => '19', + ], [ + 'id' => '20', + 'locale' => 'en', + 'name' => 'Height', + 'attribute_id' => '20', + ], [ + 'id' => '21', + 'locale' => 'en', + 'name' => 'Depth', + 'attribute_id' => '21', + ], [ + 'id' => '22', + 'locale' => 'en', + 'name' => 'Weight', + 'attribute_id' => '22', + ], [ + 'id' => '23', + 'locale' => 'en', + 'name' => 'Color', + 'attribute_id' => '23', + ], [ + 'id' => '24', + 'locale' => 'en', + 'name' => 'Size', + 'attribute_id' => '24', + ], [ + 'id' => '25', + 'locale' => 'en', + 'name' => 'Brand', + 'attribute_id' => '25', + ], [ + 'id' => '26', + 'locale' => 'en', + 'name' => 'Allow Guest Checkout', + 'attribute_id' => '26', + ] ]); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php index c80c3f841..05e023153 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeController.php @@ -5,12 +5,6 @@ namespace Webkul\Attribute\Http\Controllers; use Illuminate\Support\Facades\Event; use Webkul\Attribute\Repositories\AttributeRepository; -/** - * Catalog attribute controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AttributeController extends Controller { /** @@ -23,14 +17,14 @@ class AttributeController extends Controller /** * AttributeRepository object * - * @var array + * @var \Webkul\Attribute\Repositories\AttributeRepository */ protected $attributeRepository; /** * Create a new controller instance. * - * @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository + * @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository * @return void */ public function __construct(AttributeRepository $attributeRepository) @@ -68,9 +62,9 @@ class AttributeController extends Controller public function store() { $this->validate(request(), [ - 'code' => ['required', 'unique:attributes,code', new \Webkul\Core\Contracts\Validations\Code], + 'code' => ['required', 'unique:attributes,code', new \Webkul\Core\Contracts\Validations\Code], 'admin_name' => 'required', - 'type' => 'required' + 'type' => 'required', ]); $data = request()->all(); @@ -106,9 +100,9 @@ class AttributeController extends Controller public function update($id) { $this->validate(request(), [ - 'code' => ['required', 'unique:attributes,code,' . $id, new \Webkul\Core\Contracts\Validations\Code], + 'code' => ['required', 'unique:attributes,code,' . $id, new \Webkul\Core\Contracts\Validations\Code], 'admin_name' => 'required', - 'type' => 'required' + 'type' => 'required', ]); $attribute = $this->attributeRepository->update(request()->all(), $id); @@ -148,11 +142,12 @@ class AttributeController extends Controller /** * Remove the specified resources from database * - * @return response \Illuminate\Http\Response + * @return \Illuminate\Http\Response */ public function massDestroy() { $suppressFlash = false; + if (request()->isMethod('post')) { $indexes = explode(',', request()->input('indexes')); @@ -162,23 +157,25 @@ class AttributeController extends Controller try { if ($attribute->is_user_defined) { $suppressFlash = true; + $this->attributeRepository->delete($value); - } else { session()->flash('error', trans('admin::app.response.user-define-error', ['name' => 'Attribute'])); } } catch (\Exception $e) { report($e); + $suppressFlash = true; continue; } } - if ($suppressFlash) + if ($suppressFlash) { session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', ['resource' => 'attributes'])); - else + } else { session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'attributes'])); + } return redirect()->back(); } else { diff --git a/packages/Webkul/Attribute/src/Http/Controllers/AttributeFamilyController.php b/packages/Webkul/Attribute/src/Http/Controllers/AttributeFamilyController.php index 377231045..af0fa058b 100755 --- a/packages/Webkul/Attribute/src/Http/Controllers/AttributeFamilyController.php +++ b/packages/Webkul/Attribute/src/Http/Controllers/AttributeFamilyController.php @@ -5,12 +5,6 @@ namespace Webkul\Attribute\Http\Controllers; use Webkul\Attribute\Repositories\AttributeFamilyRepository; use Webkul\Attribute\Repositories\AttributeRepository; -/** - * Catalog family controller - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AttributeFamilyController extends Controller { /** @@ -23,22 +17,22 @@ class AttributeFamilyController extends Controller /** * AttributeFamilyRepository object * - * @var Object + * @var \Webkul\Attribute\Repositories\AttributeFamilyRepository */ protected $attributeFamilyRepository; /** * AttributeRepository object * - * @var Object + * @var \Webkul\Attribute\Repositories\AttributeRepository */ protected $attributeRepository; /** * Create a new controller instance. * - * @param \Webkul\Attribute\Repositories\AttributeFamilyRepository $attributeFamilyRepository - * @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository + * @param \Webkul\Attribute\Repositories\AttributeFamilyRepository $attributeFamilyRepository + * @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository * @return void */ public function __construct( @@ -86,7 +80,7 @@ class AttributeFamilyController extends Controller { $this->validate(request(), [ 'code' => ['required', 'unique:attribute_families,code', new \Webkul\Core\Contracts\Validations\Code], - 'name' => 'required' + 'name' => 'required', ]); $attributeFamily = $this->attributeFamilyRepository->create(request()->all()); @@ -121,7 +115,7 @@ class AttributeFamilyController extends Controller { $this->validate(request(), [ 'code' => ['required', 'unique:attribute_families,code,' . $id, new \Webkul\Core\Contracts\Validations\Code], - 'name' => 'required' + 'name' => 'required', ]); $attributeFamily = $this->attributeFamilyRepository->update(request()->all(), $id); @@ -144,7 +138,7 @@ class AttributeFamilyController extends Controller if ($this->attributeFamilyRepository->count() == 1) { session()->flash('error', trans('admin::app.response.last-delete-error', ['name' => 'Family'])); - } else if ($attributeFamily->products()->count()) { + } elseif ($attributeFamily->products()->count()) { session()->flash('error', trans('admin::app.response.attribute-product-error', ['name' => 'Attribute family'])); } else { try { @@ -165,7 +159,7 @@ class AttributeFamilyController extends Controller /** * Remove the specified resources from database * - * @return response \Illuminate\Http\Response + * @return \Illuminate\Http\Response */ public function massDestroy() { @@ -185,7 +179,7 @@ class AttributeFamilyController extends Controller } } - if (!$suppressFlash) { + if (! $suppressFlash) { session()->flash('success', ('admin::app.datagrid.mass-ops.delete-success')); } else { session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'Attribute Family'])); diff --git a/packages/Webkul/Attribute/src/Models/Attribute.php b/packages/Webkul/Attribute/src/Models/Attribute.php index d095c9624..73cdfb403 100755 --- a/packages/Webkul/Attribute/src/Models/Attribute.php +++ b/packages/Webkul/Attribute/src/Models/Attribute.php @@ -9,7 +9,24 @@ class Attribute extends TranslatableModel implements AttributeContract { public $translatedAttributes = ['name']; - protected $fillable = ['code', 'admin_name', 'type', 'position', 'is_required', 'is_unique', 'validation', 'value_per_locale', 'value_per_channel', 'is_filterable', 'is_configurable', 'is_visible_on_front', 'is_user_defined', 'swatch_type', 'use_in_flat', 'is_comparable']; + protected $fillable = [ + 'code', + 'admin_name', + 'type', + 'position', + 'is_required', + 'is_unique', + 'validation', + 'value_per_locale', + 'value_per_channel', + 'is_filterable', + 'is_configurable', + 'is_visible_on_front', + 'is_user_defined', + 'swatch_type', + 'use_in_flat', + 'is_comparable', + ]; // protected $with = ['options']; diff --git a/packages/Webkul/Attribute/src/Models/AttributeGroup.php b/packages/Webkul/Attribute/src/Models/AttributeGroup.php index 091f7077a..5ec2b8d3c 100755 --- a/packages/Webkul/Attribute/src/Models/AttributeGroup.php +++ b/packages/Webkul/Attribute/src/Models/AttributeGroup.php @@ -17,7 +17,7 @@ class AttributeGroup extends Model implements AttributeGroupContract public function custom_attributes() { return $this->belongsToMany(AttributeProxy::modelClass(), 'attribute_group_mappings') - ->withPivot('position') - ->orderBy('pivot_position', 'asc'); + ->withPivot('position') + ->orderBy('pivot_position', 'asc'); } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Models/AttributeOption.php b/packages/Webkul/Attribute/src/Models/AttributeOption.php index ad81ea63a..4b86e6abf 100755 --- a/packages/Webkul/Attribute/src/Models/AttributeOption.php +++ b/packages/Webkul/Attribute/src/Models/AttributeOption.php @@ -12,7 +12,12 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra public $translatedAttributes = ['label']; - protected $fillable = ['admin_name', 'swatch_value', 'sort_order', 'attribute_id']; + protected $fillable = [ + 'admin_name', + 'swatch_value', + 'sort_order', + 'attribute_id', + ]; /** * Get the attribute that owns the attribute option. @@ -27,8 +32,9 @@ class AttributeOption extends TranslatableModel implements AttributeOptionContra */ public function swatch_value_url() { - if ($this->swatch_value && $this->attribute->swatch_type == 'image') + if ($this->swatch_value && $this->attribute->swatch_type == 'image') { return Storage::url($this->swatch_value); + } return; } diff --git a/packages/Webkul/Attribute/src/Providers/AttributeServiceProvider.php b/packages/Webkul/Attribute/src/Providers/AttributeServiceProvider.php index 72a4daea1..6fa64e726 100755 --- a/packages/Webkul/Attribute/src/Providers/AttributeServiceProvider.php +++ b/packages/Webkul/Attribute/src/Providers/AttributeServiceProvider.php @@ -18,14 +18,4 @@ class AttributeServiceProvider extends ServiceProvider $this->app->make(EloquentFactory::class)->load(__DIR__ . '/../Database/Factories'); } - - /** - * Register services. - * - * @return void - */ - public function register() - { - - } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Repositories/AttributeFamilyRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeFamilyRepository.php index d6a00c84b..608b7122c 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeFamilyRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeFamilyRepository.php @@ -9,33 +9,27 @@ use Webkul\Attribute\Repositories\AttributeGroupRepository; use Illuminate\Container\Container as App; use Illuminate\Support\Str; -/** - * Attribute Reposotory - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AttributeFamilyRepository extends Repository { /** * AttributeRepository object * - * @var Object + * @var \Webkul\Attribute\Repositories\AttributeRepository */ protected $attributeRepository; /** * AttributeGroupRepository object * - * @var Object + * @var \Webkul\Attribute\Repositories\AttributeGroupRepository */ protected $attributeGroupRepository; /** * Create a new controller instance. * - * @param Webkul\Attribute\Repositories\AttributeRepository $attributeRepository - * @param Webkul\Attribute\Repositories\AttributeGroupRepository $attributeGroupRepository + * @param \Webkul\Attribute\Repositories\AttributeRepository $attributeRepository + * @param \Webkul\Attribute\Repositories\AttributeGroupRepository $attributeGroupRepository * @return void */ public function __construct( @@ -62,20 +56,24 @@ class AttributeFamilyRepository extends Repository } /** - * @param array $data - * @return mixed + * @param array $data + * @return \Webkul\Attribute\Contracts\AttributeFamily */ public function create(array $data) { Event::dispatch('catalog.attribute_family.create.before'); $attributeGroups = isset($data['attribute_groups']) ? $data['attribute_groups'] : []; + unset($data['attribute_groups']); + $family = $this->model->create($data); foreach ($attributeGroups as $group) { $custom_attributes = isset($group['custom_attributes']) ? $group['custom_attributes'] : []; + unset($group['custom_attributes']); + $attributeGroup = $family->attribute_groups()->create($group); foreach ($custom_attributes as $key => $attribute) { @@ -95,10 +93,10 @@ class AttributeFamilyRepository extends Repository } /** - * @param array $data - * @param $id - * @param string $attribute - * @return mixed + * @param array $data + * @param int $id + * @param string $attribute + * @return \Webkul\Attribute\Contracts\AttributeFamily */ public function update(array $data, $id, $attribute = "id") { @@ -118,6 +116,7 @@ class AttributeFamilyRepository extends Repository if (isset($attributeGroupInputs['custom_attributes'])) { foreach ($attributeGroupInputs['custom_attributes'] as $key => $attribute) { $attributeModel = $this->attributeRepository->find($attribute['id']); + $attributeGroup->custom_attributes()->save($attributeModel, ['position' => $key + 1]); } } @@ -127,6 +126,7 @@ class AttributeFamilyRepository extends Repository } $attributeGroup = $this->attributeGroupRepository->find($attributeGroupId); + $attributeGroup->update($attributeGroupInputs); $attributeIds = $attributeGroup->custom_attributes()->get()->pluck('id'); @@ -137,6 +137,7 @@ class AttributeFamilyRepository extends Repository $attributeIds->forget($index); } else { $attributeModel = $this->attributeRepository->find($attribute['id']); + $attributeGroup->custom_attributes()->save($attributeModel, ['position' => $key + 1]); } } @@ -158,17 +159,22 @@ class AttributeFamilyRepository extends Repository return $family; } + + /** + * @return array + */ public function getPartial() { $attributeFamilies = $this->model->all(); - $trimmed = array(); + + $trimmed = []; foreach ($attributeFamilies as $key => $attributeFamily) { if ($attributeFamily->name != null || $attributeFamily->name != "") { $trimmed[$key] = [ - 'id' => $attributeFamily->id, + 'id' => $attributeFamily->id, 'code' => $attributeFamily->code, - 'name' => $attributeFamily->name + 'name' => $attributeFamily->name, ]; } } @@ -177,7 +183,7 @@ class AttributeFamilyRepository extends Repository } /** - * @param $id + * @param int $id * @return void */ public function delete($id) diff --git a/packages/Webkul/Attribute/src/Repositories/AttributeGroupRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeGroupRepository.php index 7f0bc0ed6..4840680c7 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeGroupRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeGroupRepository.php @@ -4,12 +4,6 @@ namespace Webkul\Attribute\Repositories; use Webkul\Core\Eloquent\Repository; -/** - * Attribute Group Reposotory - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AttributeGroupRepository extends Repository { diff --git a/packages/Webkul/Attribute/src/Repositories/AttributeOptionRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeOptionRepository.php index 2e2238b53..65008d197 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeOptionRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeOptionRepository.php @@ -4,12 +4,6 @@ namespace Webkul\Attribute\Repositories; use Webkul\Core\Eloquent\Repository; -/** - * Attribute Option Reposotory - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AttributeOptionRepository extends Repository { @@ -24,8 +18,8 @@ class AttributeOptionRepository extends Repository } /** - * @param array $data - * @return mixed + * @param array $data + * @return \Webkul\Attribute\Contracts\AttributeOption */ public function create(array $data) { @@ -37,10 +31,10 @@ class AttributeOptionRepository extends Repository } /** - * @param array $data - * @param $id - * @param string $attribute - * @return mixed + * @param array $data + * @param int $id + * @param string $attribute + * @return \Webkul\Attribute\Contracts\AttributeOption */ public function update(array $data, $id, $attribute = "id") { @@ -52,19 +46,20 @@ class AttributeOptionRepository extends Repository } /** - * @param array $data - * @param mixed $optionId - * @return mixed + * @param array $data + * @param int $optionId + * @return void */ public function uploadSwatchImage($data, $optionId) { - if (! isset($data['swatch_value']) || ! $data['swatch_value']) + if (! isset($data['swatch_value']) || ! $data['swatch_value']) { return; + } if ($data['swatch_value'] instanceof \Illuminate\Http\UploadedFile) { parent::update([ - 'swatch_value' => $data['swatch_value']->store('attribute_option') - ], $optionId); + 'swatch_value' => $data['swatch_value']->store('attribute_option'), + ], $optionId); } } } \ No newline at end of file diff --git a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php index d5d24ba86..0eba53f4e 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php @@ -8,25 +8,19 @@ use Webkul\Attribute\Repositories\AttributeOptionRepository; use Illuminate\Container\Container as App; use Illuminate\Support\Str; -/** - * Attribute Reposotory - * - * @author Jitendra Singh - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ class AttributeRepository extends Repository { /** * AttributeOptionRepository object * - * @var Object + * @var \Webkul\Attribute\Repositories\AttributeOptionRepository */ protected $attributeOptionRepository; /** * Create a new repository instance. * - * @param Webkul\Attribute\Repositories\AttributeOptionRepository $attributeOptionRepository + * @param \Webkul\Attribute\Repositories\AttributeOptionRepository $attributeOptionRepository * @return void */ public function __construct( @@ -50,8 +44,8 @@ class AttributeRepository extends Repository } /** - * @param array $data - * @return mixed + * @param array $data + * @return \Webkul\Attribute\Contracts\Attribute */ public function create(array $data) { @@ -60,14 +54,16 @@ class AttributeRepository extends Repository $data = $this->validateUserInput($data); $options = isset($data['options']) ? $data['options'] : []; + unset($data['options']); + $attribute = $this->model->create($data); if (in_array($attribute->type, ['select', 'multiselect', 'checkbox']) && count($options)) { foreach ($options as $optionInputs) { $this->attributeOptionRepository->create(array_merge([ - 'attribute_id' => $attribute->id - ], $optionInputs)); + 'attribute_id' => $attribute->id, + ], $optionInputs)); } } @@ -77,10 +73,10 @@ class AttributeRepository extends Repository } /** - * @param array $data - * @param $id - * @param string $attribute - * @return mixed + * @param array $data + * @param int $id + * @param string $attribute + * @return \Webkul\Attribute\Contracts\Attribute */ public function update(array $data, $id, $attribute = "id") { @@ -99,8 +95,8 @@ class AttributeRepository extends Repository foreach ($data['options'] as $optionId => $optionInputs) { if (Str::contains($optionId, 'option_')) { $this->attributeOptionRepository->create(array_merge([ - 'attribute_id' => $attribute->id, - ], $optionInputs)); + 'attribute_id' => $attribute->id, + ], $optionInputs)); } else { if (is_numeric($index = $previousOptionIds->search($optionId))) { $previousOptionIds->forget($index); @@ -122,7 +118,7 @@ class AttributeRepository extends Repository } /** - * @param $id + * @param int $id * @return void */ public function delete($id) @@ -135,7 +131,7 @@ class AttributeRepository extends Repository } /** - * @param array $data + * @param array $data * @return array */ public function validateUserInput($data) @@ -164,6 +160,8 @@ class AttributeRepository extends Repository } /** + * + * @param array $codes * @return array */ public function getProductDefaultAttributes($codes = null) @@ -180,48 +178,54 @@ class AttributeRepository extends Repository 'special_price', 'special_price_from', 'special_price_to', - 'status' + 'status', ], $attributeColumns); - if (in_array('*', $codes)) + if (in_array('*', $codes)) { return $this->all($attributeColumns); + } return $this->findWhereIn('code', $codes, $attributeColumns); } /** - * @return Object + * @param string $code + * @return \Webkul\Attribute\Contracts\Attribute */ public function getAttributeByCode($code) { static $attributes = []; - if (array_key_exists($code, $attributes)) + if (array_key_exists($code, $attributes)) { return $attributes[$code]; + } return $attributes[$code] = $this->findOneByField('code', $code); } /** - * @return Object + * @param \Webkul\Attribute\Contracts\AttributeFamily $attributeFamily + * @return \Webkul\Attribute\Contracts\Attribute */ public function getFamilyAttributes($attributeFamily) { static $attributes = []; - if (array_key_exists($attributeFamily->id, $attributes)) + if (array_key_exists($attributeFamily->id, $attributes)) { return $attributes[$attributeFamily->id]; + } return $attributes[$attributeFamily->id] = $attributeFamily->custom_attributes; } /** - * @return Object + * @return array */ public function getPartial() { $attributes = $this->model->all(); - $trimmed = array(); + + $trimmed = []; foreach($attributes as $key => $attribute) { if ($attribute->code != 'tax_category_id' @@ -229,24 +233,24 @@ class AttributeRepository extends Repository $attribute->type == 'select' || $attribute->type == 'multiselect' || $attribute->code == 'sku' - )) { + )) { if ($attribute->options()->exists()) { array_push($trimmed, [ - 'id' => $attribute->id, - 'name' => $attribute->admin_name, - 'type' => $attribute->type, - 'code' => $attribute->code, + 'id' => $attribute->id, + 'name' => $attribute->admin_name, + 'type' => $attribute->type, + 'code' => $attribute->code, 'has_options' => true, - 'options' => $attribute->options + 'options' => $attribute->options, ]); } else { array_push($trimmed, [ - 'id' => $attribute->id, - 'name' => $attribute->admin_name, - 'type' => $attribute->type, - 'code' => $attribute->code, + 'id' => $attribute->id, + 'name' => $attribute->admin_name, + 'type' => $attribute->type, + 'code' => $attribute->code, 'has_options' => false, - 'options' => null + 'options' => null, ]); } diff --git a/packages/Webkul/BookingProduct/.gitignore b/packages/Webkul/BookingProduct/.gitignore new file mode 100755 index 000000000..6376db975 --- /dev/null +++ b/packages/Webkul/BookingProduct/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/package-lock.json +npm-debug.log \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/package.json b/packages/Webkul/BookingProduct/package.json new file mode 100644 index 000000000..16e824391 --- /dev/null +++ b/packages/Webkul/BookingProduct/package.json @@ -0,0 +1,22 @@ +{ + "private": true, + "scripts": { + "dev": "npm run development", + "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch-poll": "cross-env npm run watch -- --watch-poll --progress", + "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "prod": "npm run production", + "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" + }, + "devDependencies": { + "axios": "^0.19.0", + "cross-env": "^6.0.3", + "jquery": "^3.4.1", + "laravel-mix": "^5.0.0", + "laravel-mix-merge-manifest": "^0.1.2", + "sass": "^1.25.0", + "sass-loader": "^8.0.2", + "vue": "^2.6.10" + } +} diff --git a/packages/Webkul/BookingProduct/publishable/assets/css/default-booking.css b/packages/Webkul/BookingProduct/publishable/assets/css/default-booking.css new file mode 100644 index 000000000..aae87165b --- /dev/null +++ b/packages/Webkul/BookingProduct/publishable/assets/css/default-booking.css @@ -0,0 +1 @@ +.bp-location-icon{background-image:url(../images/location.svg);width:32px;height:32px}.bp-slot-icon{background-image:url(../images/slot.svg);width:32px;height:32px}.bp-phone-icon{background-image:url(../images/phone.svg);width:32px;height:32px}.booking-information{margin-bottom:15px;border-top:1px solid #e8e8e8;padding-top:15px}.booking-information .booking-info-row{padding-left:32px;margin-bottom:20px;position:relative}.booking-information .booking-info-row .icon{position:absolute;left:0;top:-4px}.booking-information .booking-info-row .title{color:#5e5e5e;display:block;margin-bottom:5px}.booking-information .booking-info-row .value{display:block;margin-bottom:5px}.booking-information .booking-info-row .value .text-danger{color:#ff5656}.booking-information .booking-info-row .toggle{color:#0041ff;cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.booking-information .booking-info-row .toggle .icon{position:relative;width:10px;height:10px;margin-left:5px;top:0}.booking-information .booking-info-row .toggle .icon.arrow-down-icon{background-image:url(../images/arrow-down.svg)!important}.booking-information .booking-info-row .toggle .icon.arrow-up-icon{background-image:url(../images/arrow-up.svg)!important}.booking-information .booking-info-row .days-availability table{margin-top:10px;border-collapse:collapse}.booking-information .booking-info-row .days-availability table tr td{padding:5px;vertical-align:top}.booking-information .booking-info-row .days-availability table tr td:first-child{padding-left:0}.booking-information .booking-info-row .days-availability table tr td:last-child{font-size:14px;padding-left:15px;padding-right:0;color:#5e5e5e}.booking-information .booking-info-row .days-availability table tr td .text-danger{color:#ff5656}.booking-information .book-slots{padding-top:25px;display:inline-block;width:100%}.booking-information .book-slots h3{font-weight:600;font-size:16px;color:#242424;margin-top:0}.booking-information .book-slots label{color:#3a3a3a}.booking-information .book-slots .control-group label,.booking-information .book-slots .form-group label{font-size:16px}.booking-information .book-slots .control-group .radio,.booking-information .book-slots .form-group .radio{display:inline-block}.booking-information .book-slots .control-group-container{width:100%;float:left}.booking-information .book-slots .control-group-container .control-group:not(.quantity),.booking-information .book-slots .control-group-container .form-group:not(.quantity){width:50%;float:left}.booking-information .book-slots .control-group-container .control-group:not(.quantity) .control,.booking-information .book-slots .control-group-container .control-group:not(.quantity) .form-style,.booking-information .book-slots .control-group-container .form-group:not(.quantity) .control,.booking-information .book-slots .control-group-container .form-group:not(.quantity) .form-style{width:100%}.booking-information .book-slots .control-group-container .control-group:not(.quantity).date,.booking-information .book-slots .control-group-container .form-group:not(.quantity).date{padding-right:5px}.booking-information .book-slots .control-group-container .control-group:not(.quantity).date:after,.booking-information .book-slots .control-group-container .form-group:not(.quantity).date:after{position:absolute;top:14px;right:10px}.booking-information .book-slots .control-group-container .control-group:not(.quantity).slots:first-child,.booking-information .book-slots .control-group-container .form-group:not(.quantity).slots:first-child{padding-right:5px}.booking-information .book-slots .control-group-container .control-group:not(.quantity).slots:last-child,.booking-information .book-slots .control-group-container .form-group:not(.quantity).slots:last-child{padding-left:5px}.booking-information .book-slots .ticket-list .ticket-item{width:100%;display:inline-block;padding:16px 0;border-bottom:1px solid #e8e8e8}.booking-information .book-slots .ticket-list .ticket-item:last-child{border-bottom:0}.booking-information .book-slots .ticket-list .ticket-item .ticket-info{width:50%;float:left}.booking-information .book-slots .ticket-list .ticket-item .ticket-info .ticket-name{color:#242424;margin-bottom:12px}.booking-information .book-slots .ticket-list .ticket-item .ticket-info .ticket-price{color:#5e5e5e}.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity{width:50%;display:inline-block;text-align:right}.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .control-group,.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .form-group{margin:0}.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .control-group.quantity,.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .form-group.quantity{max-width:none;width:auto;text-align:center;margin-bottom:0;border-top:0;padding-top:0}.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .control-group.quantity label,.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .form-group.quantity label{display:none}.booking-information .book-slots .ticket-list .ticket-item p{color:#242424;margin-bottom:0;font-weight:400}.booking-information .book-slots .ticket-total{font-size:16px;font-weight:600;color:#242424;padding-top:16px;border-top:1px solid #e8e8e8}.booking-information .book-slots .ticket-total>div{margin-bottom:12px}.booking-information .book-slots .ticket-total>div:last-child{margin-bottom:0}.booking-information .book-slots .ticket-total>div p{color:#242424;font-weight:400;margin-top:4px} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/publishable/assets/css/velocity-booking.css b/packages/Webkul/BookingProduct/publishable/assets/css/velocity-booking.css new file mode 100644 index 000000000..de40fbfab --- /dev/null +++ b/packages/Webkul/BookingProduct/publishable/assets/css/velocity-booking.css @@ -0,0 +1 @@ +.bp-location-icon{background-image:url(../images/location.svg);width:32px;height:32px}.bp-slot-icon{background-image:url(../images/slot.svg);width:32px;height:32px}.bp-phone-icon{background-image:url(../images/phone.svg);width:32px;height:32px}.booking-information{margin-bottom:15px}.booking-information .booking-info-row{padding-left:32px;margin-bottom:20px;position:relative}.booking-information .booking-info-row .icon{position:absolute;left:0;top:-4px}.booking-information .booking-info-row .title{color:#5e5e5e;display:block;margin-bottom:5px}.booking-information .booking-info-row .value{display:block;margin-bottom:5px}.booking-information .booking-info-row .value .text-danger{color:#ff5656}.booking-information .booking-info-row .toggle{color:#0041ff;cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.booking-information .booking-info-row .toggle .icon{position:relative;width:10px;height:10px;margin-left:5px;top:0}.booking-information .booking-info-row .toggle .icon.arrow-down-icon{background-image:url(../images/arrow-down.svg)!important}.booking-information .booking-info-row .toggle .icon.arrow-up-icon{background-image:url(../images/arrow-up.svg)!important}.booking-information .booking-info-row .days-availability table{margin-top:10px;border-collapse:collapse}.booking-information .booking-info-row .days-availability table tr td{padding:5px;vertical-align:top}.booking-information .booking-info-row .days-availability table tr td:first-child{padding-left:0}.booking-information .booking-info-row .days-availability table tr td:last-child{font-size:14px;padding-left:15px;padding-right:0;color:#5e5e5e}.booking-information .booking-info-row .days-availability table tr td .text-danger{color:#ff5656}.booking-information .book-slots{display:inline-block;width:100%}.booking-information .book-slots h3{font-weight:600;font-size:16px;color:#242424;margin-top:0}.booking-information .book-slots label{color:#3a3a3a}.booking-information .book-slots .control-group label,.booking-information .book-slots .form-group label{font-size:16px}.booking-information .book-slots .control-group .radio,.booking-information .book-slots .form-group .radio{display:inline-block}.booking-information .book-slots .control-group-container{width:100%;float:left}.booking-information .book-slots .control-group-container .control-group:not(.quantity),.booking-information .book-slots .control-group-container .form-group:not(.quantity){width:50%;float:left}.booking-information .book-slots .control-group-container .control-group:not(.quantity) .control,.booking-information .book-slots .control-group-container .control-group:not(.quantity) .form-style,.booking-information .book-slots .control-group-container .form-group:not(.quantity) .control,.booking-information .book-slots .control-group-container .form-group:not(.quantity) .form-style{width:100%}.booking-information .book-slots .control-group-container .control-group:not(.quantity).date,.booking-information .book-slots .control-group-container .form-group:not(.quantity).date{padding-right:5px}.booking-information .book-slots .control-group-container .control-group:not(.quantity).date:after,.booking-information .book-slots .control-group-container .form-group:not(.quantity).date:after{position:absolute;top:14px;right:10px}.booking-information .book-slots .control-group-container .control-group:not(.quantity).slots:first-child,.booking-information .book-slots .control-group-container .form-group:not(.quantity).slots:first-child{padding-right:5px}.booking-information .book-slots .control-group-container .control-group:not(.quantity).slots:last-child,.booking-information .book-slots .control-group-container .form-group:not(.quantity).slots:last-child{padding-left:5px}.booking-information .book-slots .ticket-list .ticket-item{width:100%;display:inline-block;padding:16px 0;border-bottom:1px solid #e8e8e8}.booking-information .book-slots .ticket-list .ticket-item:last-child{border-bottom:0}.booking-information .book-slots .ticket-list .ticket-item .ticket-info{width:50%;float:left}.booking-information .book-slots .ticket-list .ticket-item .ticket-info .ticket-name{color:#242424;margin-bottom:12px}.booking-information .book-slots .ticket-list .ticket-item .ticket-info .ticket-price{color:#5e5e5e}.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity{width:50%;display:inline-block;text-align:right}.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .control-group,.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .form-group{margin:0}.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .control-group.quantity,.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .form-group.quantity{max-width:none;width:auto;text-align:center;margin-bottom:0;border-top:0;padding-top:0}.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .control-group.quantity label,.booking-information .book-slots .ticket-list .ticket-item .ticket-quantity .form-group.quantity label{display:none}.booking-information .book-slots .ticket-list .ticket-item p{color:#242424;margin-bottom:0;font-weight:400}.booking-information .book-slots .ticket-total{font-size:16px;font-weight:600;color:#242424;padding-top:16px}.booking-information .book-slots .ticket-total>div{margin-bottom:12px}.booking-information .book-slots .ticket-total>div:last-child{margin-bottom:0}.booking-information .book-slots .ticket-total>div p{color:#242424;font-weight:400;margin-top:4px} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/publishable/assets/images/arrow-down.svg b/packages/Webkul/BookingProduct/publishable/assets/images/arrow-down.svg new file mode 100644 index 000000000..dd459433e --- /dev/null +++ b/packages/Webkul/BookingProduct/publishable/assets/images/arrow-down.svg @@ -0,0 +1,10 @@ + + + + icon-dropdown + Created with Sketch. + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/publishable/assets/images/arrow-up.svg b/packages/Webkul/BookingProduct/publishable/assets/images/arrow-up.svg new file mode 100644 index 000000000..4ebba93f5 --- /dev/null +++ b/packages/Webkul/BookingProduct/publishable/assets/images/arrow-up.svg @@ -0,0 +1,10 @@ + + + + icon-dropdown-up + Created with Sketch. + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/publishable/assets/images/location.svg b/packages/Webkul/BookingProduct/publishable/assets/images/location.svg new file mode 100644 index 000000000..19fd55a0d --- /dev/null +++ b/packages/Webkul/BookingProduct/publishable/assets/images/location.svg @@ -0,0 +1,11 @@ + + + + tab/heading/icon/address + Created with Sketch. + + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/publishable/assets/images/phone.svg b/packages/Webkul/BookingProduct/publishable/assets/images/phone.svg new file mode 100644 index 000000000..e132e7b15 --- /dev/null +++ b/packages/Webkul/BookingProduct/publishable/assets/images/phone.svg @@ -0,0 +1,18 @@ + + + + icon-menu copy + Created with Sketch. + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/publishable/assets/images/slot.svg b/packages/Webkul/BookingProduct/publishable/assets/images/slot.svg new file mode 100644 index 000000000..18d00bd75 --- /dev/null +++ b/packages/Webkul/BookingProduct/publishable/assets/images/slot.svg @@ -0,0 +1,15 @@ + + + + tab/heading/icon/calender + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/publishable/assets/mix-manifest.json b/packages/Webkul/BookingProduct/publishable/assets/mix-manifest.json new file mode 100644 index 000000000..866358cdf --- /dev/null +++ b/packages/Webkul/BookingProduct/publishable/assets/mix-manifest.json @@ -0,0 +1,4 @@ +{ + "/css/default-booking.css": "/css/default-booking.css?id=3607d6ec4cb93857b42c", + "/css/velocity-booking.css": "/css/velocity-booking.css?id=64d628792a52ad6151b7" +} diff --git a/packages/Webkul/BookingProduct/src/Config/product_types.php b/packages/Webkul/BookingProduct/src/Config/product_types.php new file mode 100644 index 000000000..b480d2f96 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Config/product_types.php @@ -0,0 +1,10 @@ + [ + 'key' => 'booking', + 'name' => 'Booking', + 'class' => 'Webkul\BookingProduct\Type\Booking', + 'sort' => 7, + ] +]; \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Contracts/Booking.php b/packages/Webkul/BookingProduct/src/Contracts/Booking.php new file mode 100644 index 000000000..1b02e9e3c --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Contracts/Booking.php @@ -0,0 +1,7 @@ +increments('id'); + $table->string('type'); + $table->integer('qty')->default(0)->nullable(); + $table->string('location')->nullable(); + $table->boolean('show_location')->default(0); + $table->boolean('available_every_week')->nullable(); + $table->date('available_from')->nullable(); + $table->date('available_to')->nullable(); + + $table->integer('product_id')->unsigned(); + $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('booking_products'); + } +} diff --git a/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154415_create_booking_product_default_slots_table.php b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154415_create_booking_product_default_slots_table.php new file mode 100644 index 000000000..5705d6773 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154415_create_booking_product_default_slots_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->string('booking_type'); + $table->integer('duration')->nullable(); + $table->integer('break_time')->nullable(); + $table->json('slots')->nullable(); + + $table->integer('booking_product_id')->unsigned(); + $table->foreign('booking_product_id')->references('id')->on('booking_products')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('booking_product_default_slots'); + } +} diff --git a/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154429_create_booking_product_appointment_slots_table.php b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154429_create_booking_product_appointment_slots_table.php new file mode 100644 index 000000000..51ee81434 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154429_create_booking_product_appointment_slots_table.php @@ -0,0 +1,37 @@ +increments('id'); + $table->integer('duration')->nullable(); + $table->integer('break_time')->nullable(); + $table->boolean('same_slot_all_days')->nullable(); + $table->json('slots')->nullable(); + + $table->integer('booking_product_id')->unsigned(); + $table->foreign('booking_product_id')->references('id')->on('booking_products')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('booking_product_appointment_slots'); + } +} diff --git a/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154440_create_booking_product_event_tickets_table.php b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154440_create_booking_product_event_tickets_table.php new file mode 100644 index 000000000..88298d4bd --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154440_create_booking_product_event_tickets_table.php @@ -0,0 +1,35 @@ +increments('id'); + $table->decimal('price', 12, 4)->default(0)->nullable(); + $table->integer('qty')->default(0)->nullable(); + + $table->integer('booking_product_id')->unsigned(); + $table->foreign('booking_product_id')->references('id')->on('booking_products')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('booking_product_event_tickets'); + } +} diff --git a/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154451_create_booking_product_rental_slots_table.php b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154451_create_booking_product_rental_slots_table.php new file mode 100644 index 000000000..38d383770 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154451_create_booking_product_rental_slots_table.php @@ -0,0 +1,38 @@ +increments('id'); + $table->string('renting_type'); + $table->decimal('daily_price', 12, 4)->default(0)->nullable(); + $table->decimal('hourly_price', 12, 4)->default(0)->nullable(); + $table->boolean('same_slot_all_days')->nullable(); + $table->json('slots')->nullable(); + + $table->integer('booking_product_id')->unsigned(); + $table->foreign('booking_product_id')->references('id')->on('booking_products')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('booking_product_rental_slots'); + } +} diff --git a/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154502_create_booking_product_table_slots_table.php b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154502_create_booking_product_table_slots_table.php new file mode 100644 index 000000000..9613558de --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Database/Migrations/2019_07_05_154502_create_booking_product_table_slots_table.php @@ -0,0 +1,40 @@ +increments('id'); + $table->string('price_type'); + $table->integer('guest_limit')->default(0); + $table->integer('duration'); + $table->integer('break_time'); + $table->integer('prevent_scheduling_before'); + $table->boolean('same_slot_all_days')->nullable(); + $table->json('slots')->nullable(); + + $table->integer('booking_product_id')->unsigned(); + $table->foreign('booking_product_id')->references('id')->on('booking_products')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('booking_product_table_slots'); + } +} diff --git a/packages/Webkul/BookingProduct/src/Database/Migrations/2020_02_18_165639_create_bookings_table.php b/packages/Webkul/BookingProduct/src/Database/Migrations/2020_02_18_165639_create_bookings_table.php new file mode 100644 index 000000000..3cb5d3fc0 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Database/Migrations/2020_02_18_165639_create_bookings_table.php @@ -0,0 +1,43 @@ +bigIncrements('id'); + $table->integer('qty')->default(0)->nullable(); + $table->integer('from')->nullable(); + $table->integer('to')->nullable(); + + $table->integer('order_item_id')->unsigned()->nullable(); + + $table->integer('booking_product_event_ticket_id')->unsigned()->nullable(); + + $table->integer('order_id')->unsigned()->nullable(); + $table->foreign('order_id')->references('id')->on('orders')->onDelete('cascade'); + + $table->integer('product_id')->unsigned()->nullable(); + $table->foreign('product_id')->references('id')->on('products')->onDelete('set null'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('bookings'); + } +} diff --git a/packages/Webkul/BookingProduct/src/Database/Migrations/2020_02_21_121201_create_booking_product_event_ticket_translations_table.php b/packages/Webkul/BookingProduct/src/Database/Migrations/2020_02_21_121201_create_booking_product_event_ticket_translations_table.php new file mode 100644 index 000000000..e5089e05b --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Database/Migrations/2020_02_21_121201_create_booking_product_event_ticket_translations_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->string('locale'); + $table->text('name')->nullable(); + $table->text('description')->nullable(); + $table->integer('booking_product_event_ticket_id')->unsigned(); + $table->unique(['booking_product_event_ticket_id', 'locale'], 'booking_product_event_ticket_translations_locale_unique'); + $table->foreign('booking_product_event_ticket_id', 'booking_product_event_ticket_translations_locale_foreign')->references('id')->on('booking_product_event_tickets')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('booking_product_event_ticket_translations'); + } +} diff --git a/packages/Webkul/BookingProduct/src/Helpers/AppointmentSlot.php b/packages/Webkul/BookingProduct/src/Helpers/AppointmentSlot.php new file mode 100644 index 000000000..0b6fa3d1a --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Helpers/AppointmentSlot.php @@ -0,0 +1,16 @@ + DefaultSlot::class, + 'appointment' => AppointmentSlot::class, + 'event' => EventTicket::class, + 'rental' => RentalSlot::class, + 'table' => TableSlot::class, + ]; + + /** + * @return array + */ + protected $daysOfWeek = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + + /** + * Create a new helper instance. + * + * @param \Webkul\BookingProduct\Repositories\BookingProductRepository $bookingProductRepository + * @param \Webkul\BookingProduct\Repositories\BookingProductDefaultSlotRepository $bookingProductDefaultSlotRepository + * @param \Webkul\BookingProduct\Repositories\BookingProductAppointmentSlotRepository $bookingProductAppointmentSlotRepository + * @param \Webkul\BookingProduct\Repositories\BookingProductEventTicketRepository $bookingProductEventTicketRepository + * @param \Webkul\BookingProduct\Repositories\BookingProductRentalSlotRepository $bookingProductRentalSlotRepository + * @param \Webkul\BookingProduct\Repositories\BookingProductTableSlotRepository $bookingProductTableSlotRepository + * @param \Webkul\BookingProduct\Repositories\BookingRepository $bookingRepository + * @return void + */ + public function __construct( + BookingProductRepository $bookingProductRepository, + BookingProductDefaultSlotRepository $bookingProductDefaultSlotRepository, + BookingProductAppointmentSlotRepository $bookingProductAppointmentSlotRepository, + BookingProductEventTicketRepository $bookingProductEventTicketRepository, + BookingProductRentalSlotRepository $bookingProductRentalSlotRepository, + BookingProductTableSlotRepository $bookingProductTableSlotRepository, + BookingRepository $bookingRepository + ) + { + $this->bookingProductRepository = $bookingProductRepository; + + $this->typeRepositories['default'] = $bookingProductDefaultSlotRepository; + + $this->typeRepositories['appointment'] = $bookingProductAppointmentSlotRepository; + + $this->typeRepositories['event'] = $bookingProductEventTicketRepository; + + $this->typeRepositories['rental'] = $bookingProductRentalSlotRepository; + + $this->typeRepositories['table'] = $bookingProductTableSlotRepository; + + $this->bookingRepository = $bookingRepository; + } + + /** + * Returns the booking type hepler instance + * + * @param string $type + * @return array + */ + public function getTypeHepler($type) + { + return $this->typeHelpers[$type]; + } + + /** + * Returns the booking information + * + * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct + * @return array + */ + public function getWeekSlotDurations($bookingProduct) + { + $slotsByDays = []; + + $bookingProductSlot = $this->typeRepositories[$bookingProduct->type]->findOneByField('booking_product_id', $bookingProduct->id); + + $availabileDays = $this->getAvailableWeekDays($bookingProduct); + + foreach ($this->daysOfWeek as $index => $isOpen) { + $slots = []; + + if ($isOpen) { + $slots = $bookingProductSlot->same_slot_all_days ? $bookingProductSlot->slots : ($bookingProductSlot->slots[$index] ?? []); + } + + $slotsByDays[] = [ + 'name' => trans($this->daysOfWeek[$index]), + 'slots' => isset($availabileDays[$index]) ? $this->conver24To12Hours($slots) : [], + ]; + } + + return $slotsByDays; + } + + /** + * Returns html of slots for a current day + * + * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct + * @return string + */ + public function getTodaySlotsHtml($bookingProduct) + { + $slots = []; + + foreach ($this->getTodaySlots($bookingProduct) as $slot) { + $slots[] = $slot['from'] . ' - ' . $slot['to']; + } + + return count($slots) + ? implode(' | ', $slots) + : '' . trans('bookingproduct::app.shop.products.closed') . ''; + } + + /** + * Returns slots for a current day + * + * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct + * @return array + */ + public function getTodaySlots($bookingProduct) + { + $weekSlots = $this->getWeekSlotDurations($bookingProduct); + + return $weekSlots[Carbon::now()->format('w')]['slots']; + } + + /** + * Returns the available week days + * + * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct + * @return array + */ + public function getAvailableWeekDays($bookingProduct) + { + if ($bookingProduct->available_every_week) { + return $this->daysOfWeek; + } + + $days = []; + + $currentTime = Carbon::now(); + + $availableFrom = ! $bookingProduct->available_from && $bookingProduct->available_from + ? Carbon::createFromTimeString($bookingProduct->available_from) + : clone $currentTime; + + $availableTo = ! $bookingProduct->available_from && $bookingProduct->available_to + ? Carbon::createFromTimeString($bookingProduct->available_to) + : Carbon::createFromTimeString('2080-01-01 00:00:00'); + + for ($i = 0; $i < 7; $i++) { + $date = clone $currentTime; + $date->addDays($i); + + if ($date >= $availableFrom && $date <= $availableTo) { + $days[$i] = $date->format('l'); + } + } + + return $this->sortDaysOfWeek($days); + } + + /** + * Sort days + * + * @param array $days + * @return array + */ + public function sortDaysOfWeek($days) + { + $daysAux = []; + + foreach ($days as $day) { + $key = array_search($day, $this->daysOfWeek); + + if ($key !== FALSE) { + $daysAux[$key] = $day; + } + } + + ksort($daysAux); + + return $daysAux; + } + + /** + * Convert time from 24 to 12 hour format + * + * @param array $slots + * @return array + */ + public function conver24To12Hours($slots) + { + if (! $slots) { + return []; + } + + foreach ($slots as $index => $slot) { + $slots[$index]['from'] = Carbon::createFromTimeString($slot['from'])->format("h:i a"); + $slots[$index]['to'] = Carbon::createFromTimeString($slot['to'])->format("h:i a"); + } + + return $slots; + } + + /** + * Returns slots for a perticular day + * + * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct + * @param string $date + * @return array + */ + public function getSlotsByDate($bookingProduct, $date) + { + $bookingProductSlot = $this->typeRepositories[$bookingProduct->type]->findOneByField('booking_product_id', $bookingProduct->id); + + if (! is_array($bookingProductSlot->slots) || ! count($bookingProductSlot->slots)) { + return []; + } + + $requestedDate = Carbon::createFromTimeString($date . " 00:00:00"); + + $currentTime = Carbon::now(); + + $availableFrom = ! $bookingProduct->available_every_week && $bookingProduct->available_from + ? Carbon::createFromTimeString($bookingProduct->available_from) + : Carbon::createFromTimeString($currentTime); + + $availableTo = ! $bookingProduct->available_every_week && $bookingProduct->available_from + ? Carbon::createFromTimeString($bookingProduct->available_to) + : Carbon::createFromTimeString('2080-01-01 00:00:00'); + + $timeDurations = $bookingProductSlot->same_slot_all_days + ? $bookingProductSlot->slots + : ($bookingProductSlot->slots[$requestedDate->format('w')] ?? []); + + $slots = []; + + foreach ($timeDurations as $timeDuration) { + $fromChunks = explode(':', $timeDuration['from']); + $toChunks = explode(':', $timeDuration['to']); + + $startDayTime = Carbon::createFromTimeString($requestedDate->format('Y-m-d') . ' 00:00:00'); + $startDayTime->addMinutes(($fromChunks[0] * 60) + $fromChunks[1]); + $tempStartDayTime = clone $startDayTime; + + $endDayTime = Carbon::createFromTimeString($requestedDate->format('Y-m-d') . ' 00:00:00'); + $endDayTime->addMinutes(($toChunks[0] * 60) + $toChunks[1]); + + $isFirstIteration = true; + + while (1) { + $from = clone $tempStartDayTime; + $tempStartDayTime->addMinutes($bookingProductSlot->duration); + + if ($isFirstIteration) { + $isFirstIteration = false; + } else { + $from->modify('+' . $bookingProductSlot->break_time . ' minutes'); + $tempStartDayTime->modify('+' . $bookingProductSlot->break_time . ' minutes'); + } + + $to = clone $tempStartDayTime; + + if (($startDayTime <= $from && $from <= $availableTo) + && ($availableTo >= $to && $to >= $startDayTime) + && ($startDayTime <= $from && $from <= $endDayTime) + && ($endDayTime >= $to && $to >= $startDayTime) + ) { + // Get already ordered qty for this slot + $orderedQty = 0; + + $qty = isset($timeDuration['qty']) ? ( $timeDuration['qty'] - $orderedQty ) : 1; + + if ($qty && $currentTime <= $from) { + $slots[] = [ + 'from' => $from->format('h:i A'), + 'to' => $to->format('h:i A'), + 'timestamp' => $from->getTimestamp() . '-' . $to->getTimestamp(), + 'qty' => $qty, + ]; + } + } else { + break; + } + } + } + + return $slots; + } + + /** + * @param \Webkul\Ceckout\Contracts\CartItem|array $cartItem + * @return bool + */ + public function isItemHaveQuantity($cartItem) + { + $bookingProduct = $this->bookingProductRepository->findOneByField('product_id', $cartItem['product_id']); + + if ($bookingProduct->qty - $this->getBookedQuantity($cartItem) < $cartItem['quantity']) { + return false; + } + + return true; + } + + /** + * @param array $cartProducts + * @return bool + */ + public function isSlotAvailable($cartProducts) + { + foreach ($cartProducts as $cartProduct) { + if (! $this->isItemHaveQuantity($cartProduct)) { + return false; + } + } + + return true; + } + + /** + * @param array $data + * @return int + */ + public function getBookedQuantity($data) + { + $timestamps = explode('-', $data['additional']['booking']['slot']); + + $result = $this->bookingRepository->getModel() + ->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id') + ->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked')) + ->where('bookings.product_id', $data['product_id']) + ->where('bookings.from', $timestamps[0]) + ->where('bookings.to', $timestamps[1]) + ->first(); + + return ! is_null($result->total_qty_booked) ? $result->total_qty_booked : 0; + } + + /** + * Returns additional cart item information + * + * @param array $data + * @return array + */ + public function getCartItemOptions($data) + { + $bookingProduct = $this->bookingProductRepository->findOneByField('product_id', $data['product_id']); + + if (! $bookingProduct) { + return $data; + } + + switch ($bookingProduct->type) { + case 'event': + $ticket = $bookingProduct->event_tickets()->find($data['booking']['ticket_id']); + + $data['attributes'] = [ + [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.event-ticket'), + 'option_id' => 0, + 'option_label' => $ticket->name, + ], [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.event-from'), + 'option_id' => 0, + 'option_label' => Carbon::createFromTimeString($bookingProduct->available_from)->format('d F, Y'), + ], [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.event-till'), + 'option_id' => 0, + 'option_label' => Carbon::createFromTimeString($bookingProduct->available_to)->format('d F, Y'), + ] + ]; + + break; + + case 'rental': + $rentingType = $data['booking']['renting_type'] ?? $bookingProduct->rental_slot->renting_type; + + if ($rentingType == 'daily') { + $from = Carbon::createFromTimeString($data['booking']['date_from'] . " 00:00:01")->format('d F, Y'); + + $to = Carbon::createFromTimeString($data['booking']['date_to'] . " 23:59:59")->format('d F, Y'); + } else { + $from = Carbon::createFromTimestamp($data['booking']['slot']['from'])->format('d F, Y h:i A'); + + $to = Carbon::createFromTimestamp($data['booking']['slot']['to'])->format('d F, Y h:i A'); + } + + $data['attributes'] = [ + [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.rent-type'), + 'option_id' => 0, + 'option_label' => trans('bookingproduct::app.shop.cart.' . $rentingType), + ], [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.rent-from'), + 'option_id' => 0, + 'option_label' => $from, + ], [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.rent-till'), + 'option_id' => 0, + 'option_label' => $to, + ] + ]; + + break; + + case 'table': + $timestamps = explode('-', $data['booking']['slot']); + + $data['attributes'] = [ + [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.booking-from'), + 'option_id' => 0, + 'option_label' => Carbon::createFromTimestamp($timestamps[0])->format('d F, Y h:i A'), + ], [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.booking-till'), + 'option_id' => 0, + 'option_label' => Carbon::createFromTimestamp($timestamps[1])->format('d F, Y h:i A'), + ] + ]; + + if ($data['booking']['note'] != '') { + $data['attributes'][2] = [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.special-note'), + 'option_id' => 0, + 'option_label' => $data['booking']['note'], + ]; + } + + break; + + default: + $timestamps = explode('-', $data['booking']['slot']); + + $data['attributes'] = [ + [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.booking-from'), + 'option_id' => 0, + 'option_label' => Carbon::createFromTimestamp($timestamps[0])->format('d F, Y h:i A'), + ], [ + 'attribute_name' => trans('bookingproduct::app.shop.cart.booking-till'), + 'option_id' => 0, + 'option_label' => Carbon::createFromTimestamp($timestamps[1])->format('d F, Y h:i A'), + ] + ]; + + break; + } + + return $data; + } + + /** + * Add booking additional prices to cart item + * + * @param array $products + * @return array + */ + public function addAdditionalPrices($products) + { + return $products; + } + + /** + * Validate cart item product price + * + * @param \Webkul\Checkout\Contracts\CartItem $item + * @return float + */ + public function validateCartItem($item) + { + $price = $item->product->getTypeInstance()->getFinalPrice(); + + if ($price == $item->base_price) { + return; + } + + $item->base_price = $price; + $item->price = core()->convertPrice($price); + + $item->base_total = $price * $item->quantity; + $item->total = core()->convertPrice($price * $item->quantity); + + $item->save(); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php b/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php new file mode 100644 index 000000000..57df90b04 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php @@ -0,0 +1,164 @@ +typeRepositories[$bookingProduct->type]->findOneByField('booking_product_id', $bookingProduct->id); + + if (! is_array($bookingProductSlot->slots) || ! count($bookingProductSlot->slots)) { + return []; + } + + $requestedDate = Carbon::createFromTimeString($date . ' 00:00:00'); + + $currentTime = Carbon::now(); + + $availableFrom = ! $bookingProduct->available_from && $bookingProduct->available_from + ? Carbon::createFromTimeString($bookingProduct->available_from) + : clone $currentTime; + + $availableTo = ! $bookingProduct->available_from && $bookingProduct->available_to + ? Carbon::createFromTimeString($bookingProduct->available_to) + : Carbon::createFromTimeString('2080-01-01 00:00:00'); + + if ($requestedDate < $currentTime + || $requestedDate < $availableFrom + || $requestedDate > $availableTo + ) { + return []; + } + + $slots = []; + + return $bookingProductSlot->booking_type == 'one' + ? $this->getOneBookingForManyDaysSlots($bookingProductSlot, $requestedDate) + : $this->getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate); + } + + /** + * Returns slots for One Booking For Many Days + * + * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct + * @param string $requestedDate + * @return array + */ + public function getOneBookingForManyDaysSlots($bookingProductSlot, $requestedDate) + { + $slots = []; + + foreach ($bookingProductSlot->slots as $timeDuration) { + if ($requestedDate->dayOfWeek != $timeDuration['from_day']) { + continue; + } + + $startDate = clone $requestedDate->modify('this ' . $this->daysOfWeek[$timeDuration['from_day']]); + + $endDate = clone $requestedDate->modify('this ' . $this->daysOfWeek[$timeDuration['to_day']]); + + $slots[] = [ + 'from' => $startDate->format('d F, Y h:i A'), + 'to' => $endDate->format('d F, Y h:i A'), + 'timestamp' => $startDate->getTimestamp() . '-' . $endDate->getTimestamp(), + ]; + } + + return $slots; + } + + /** + * Returns slots for Many Bookings for One Day + * + * @param \Webkul\BookingProduct\Contracts\BookingProductSlot $bookingProductSlot + * @param string $requestedDate + * @return array + */ + public function getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate) + { + $bookingProduct = $bookingProductSlot->booking_product; + + $currentTime = Carbon::now(); + + $availableFrom = ! $bookingProduct->available_from && $bookingProduct->available_from + ? Carbon::createFromTimeString($bookingProduct->available_from) + : clone $currentTime; + + $availableTo = ! $bookingProduct->available_from && $bookingProduct->available_to + ? Carbon::createFromTimeString($bookingProduct->available_to) + : Carbon::createFromTimeString('2080-01-01 00:00:00'); + + $timeDuration = $bookingProductSlot->slots[$requestedDate->format('w')] ?? []; + + if (! count($timeDuration) || ! $timeDuration['status']) { + return []; + } + + $slots = []; + + $fromChunks = explode(':', $timeDuration['from']); + $toChunks = explode(':', $timeDuration['to']); + + $startDayTime = Carbon::createFromTimeString($requestedDate->format('Y-m-d') . ' 00:00:00'); + $startDayTime->addMinutes(($fromChunks[0] * 60) + $fromChunks[1]); + $tempStartDayTime = clone $startDayTime; + + $endDayTime = Carbon::createFromTimeString($requestedDate->format('Y-m-d') . ' 00:00:00'); + $endDayTime->addMinutes(($toChunks[0] * 60) + $toChunks[1]); + + $isFirstIteration = true; + + while (1) { + $from = clone $tempStartDayTime; + $tempStartDayTime->addMinutes($bookingProductSlot->duration); + + if ($isFirstIteration) { + $isFirstIteration = false; + } else { + $from->modify('+' . $bookingProductSlot->break_time . ' minutes'); + $tempStartDayTime->modify('+' . $bookingProductSlot->break_time . ' minutes'); + } + + $to = clone $tempStartDayTime; + + if (($startDayTime <= $from && $from <= $availableTo) + && ($availableTo >= $to && $to >= $startDayTime) + && ($startDayTime <= $from && $from <= $endDayTime) + && ($endDayTime >= $to && $to >= $startDayTime) + ) { + // Get already ordered qty for this slot + $orderedQty = 0; + + $qty = isset($timeDuration['qty']) ? ( $timeDuration['qty'] - $orderedQty ) : 1; + + if ($qty && $currentTime <= $from) { + $slots[] = [ + 'from' => $from->format('h:i A'), + 'to' => $to->format('h:i A'), + 'timestamp' => $from->getTimestamp() . '-' . $to->getTimestamp(), + 'qty' => $qty, + ]; + } + } else { + break; + } + } + + return $slots; + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php b/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php new file mode 100644 index 000000000..f24e3f400 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php @@ -0,0 +1,141 @@ +available_from)->format('d F, Y h:i A'); + + $to = Carbon::createFromTimeString($bookingProduct->available_to)->format('d F, Y h:i A'); + + return $from . ' - ' . $to; + } + + /** + * Returns tickets + * + * @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct + * @return array + */ + public function getTickets($bookingProduct) + { + if (! $bookingProduct->event_tickets()->count()) { + return; + } + + return $this->formatPrice($bookingProduct->event_tickets); + } + + /** + * Format ticket price + * + * @param array $tickets + * @return array + */ + public function formatPrice($tickets) + { + foreach ($tickets as $index => $ticket) { + $tickets[$index]['id'] = $ticket->id; + $tickets[$index]['converted_price'] = core()->convertPrice($ticket->price); + $tickets[$index]['formated_price'] = $formatedPrice = core()->currency($ticket->price); + $tickets[$index]['formated_price_text'] = trans('bookingproduct::app.shop.products.per-ticket-price', ['price' => $formatedPrice]); + } + + return $tickets; + } + + /** + * @param \Webkul\Checkout\Contracts\CartItem|array $cartItem + * @return bool + */ + public function isItemHaveQuantity($cartItem) + { + $bookingProduct = $this->bookingProductRepository->findOneByField('product_id', $cartItem['product_id']); + + $ticket = $bookingProduct->event_tickets()->find($cartItem['additional']['booking']['ticket_id']); + + if ($ticket->qty - $this->getBookedQuantity($cartItem) < $cartItem['quantity']) { + return false; + } + + return true; + } + + /** + * @param array $data + * @return int + */ + public function getBookedQuantity($data) + { + $result = $this->bookingRepository->getModel() + ->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id') + ->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked')) + ->where('bookings.product_id', $data['product_id']) + ->where('bookings.booking_product_event_ticket_id', $data['additional']['booking']['ticket_id']) + ->first(); + + return ! is_null($result->total_qty_booked) ? $result->total_qty_booked : 0; + } + + /** + * Add booking additional prices to cart item + * + * @param array $products + * @return array + */ + public function addAdditionalPrices($products) + { + foreach ($products as $key => $product) { + $bookingProduct = $this->bookingProductRepository->findOneByField('product_id', $product['product_id']); + + $ticket = $bookingProduct->event_tickets()->find($product['additional']['booking']['ticket_id']); + + $products[$key]['price'] += core()->convertPrice($ticket->price); + $products[$key]['base_price'] += $ticket->price; + $products[$key]['total'] += (core()->convertPrice($ticket->price) * $products[$key]['quantity']); + $products[$key]['base_total'] += ($ticket->price * $products[$key]['quantity']); + } + + return $products; + } + + /** + * Validate cart item product price + * + * @param \Webkul\Checkout\Contracts\CartItem $item + * @return float + */ + public function validateCartItem($item) + { + $price = $item->product->getTypeInstance()->getFinalPrice(); + + $bookingProduct = $this->bookingProductRepository->findOneByField('product_id', $item->product_id); + + $ticket = $bookingProduct->event_tickets()->find($item->additional['booking']['ticket_id']); + + $price += $ticket->price; + + if ($price == $item->base_price) { + return; + } + + $item->base_price = $price; + $item->price = core()->convertPrice($price); + + $item->base_total = $price * $item->quantity; + $item->total = core()->convertPrice($price * $item->quantity); + + $item->save(); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Helpers/RentalSlot.php b/packages/Webkul/BookingProduct/src/Helpers/RentalSlot.php new file mode 100644 index 000000000..f6ed38ee4 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Helpers/RentalSlot.php @@ -0,0 +1,199 @@ +typeRepositories[$bookingProduct->type]->findOneByField('booking_product_id', $bookingProduct->id); + + if (! is_array($bookingProductSlot->slots) || ! count($bookingProductSlot->slots)) { + return []; + } + + $requestedDate = Carbon::createFromTimeString($date . " 00:00:00"); + + $currentTime = Carbon::now(); + + $availableFrom = ! $bookingProduct->available_every_week && $bookingProduct->available_from + ? Carbon::createFromTimeString($bookingProduct->available_from) + : Carbon::createFromTimeString($currentTime); + + $availableTo = ! $bookingProduct->available_every_week && $bookingProduct->available_from + ? Carbon::createFromTimeString($bookingProduct->available_to) + : Carbon::createFromTimeString('2080-01-01 00:00:00'); + + $timeDurations = $bookingProductSlot->same_slot_all_days + ? $bookingProductSlot->slots + : $bookingProductSlot->slots[$requestedDate->format('w')]; + + $slots = []; + + foreach ($timeDurations as $index => $timeDuration) { + $fromChunks = explode(':', $timeDuration['from']); + $toChunks = explode(':', $timeDuration['to']); + + $startDayTime = Carbon::createFromTimeString($requestedDate->format('Y-m-d') . ' 00:00:00'); + $startDayTime->addMinutes(($fromChunks[0] * 60) + $fromChunks[1]); + $tempStartDayTime = clone $startDayTime; + + $endDayTime = Carbon::createFromTimeString($requestedDate->format('Y-m-d') . ' 00:00:00'); + $endDayTime->addMinutes(($toChunks[0] * 60) + $toChunks[1]); + + while (1) { + $from = clone $tempStartDayTime; + $tempStartDayTime->addMinutes(60); + + $to = clone $tempStartDayTime; + + if (($startDayTime <= $from && $from <= $availableTo) + && ($availableTo >= $to && $to >= $startDayTime) + && ($startDayTime <= $from && $from <= $endDayTime) + && ($endDayTime >= $to && $to >= $startDayTime) + ) { + // Get already ordered qty for this slot + $orderedQty = 0; + + $qty = isset($timeDuration['qty']) ? ( $timeDuration['qty'] - $orderedQty ) : 1; + + if ($qty && $currentTime <= $from) { + if (! isset($slots[$index])) { + $slots[$index]['time'] = $startDayTime->format('h:i A') . ' - ' . $endDayTime->format('h:i A'); + } + + $slots[$index]['slots'][] = [ + 'from' => $from->format('h:i A'), + 'to' => $to->format('h:i A'), + 'from_timestamp' => $from->getTimestamp(), + 'to_timestamp' => $to->getTimestamp(), + 'qty' => $qty, + ]; + } + } else { + break; + } + } + } + + return $slots; + } + + /** + * @param array $data + * @return int + */ + public function getBookedQuantity($data) + { + $bookingProduct = $this->bookingProductRepository->findOneByField('product_id', $data['product_id']); + + $rentingType = $products[0]['additional']['booking']['renting_type'] ?? $bookingProduct->rental_slot->renting_type; + + if ($rentingType == 'daily') { + $from = Carbon::createFromTimeString($data['additional']['booking']['date_from'] . ' 00:00:01')->getTimestamp(); + + $to = Carbon::createFromTimeString($data['additional']['booking']['date_to'] . ' 23:59:59')->getTimestamp(); + } else { + $from = Carbon::createFromTimestamp($data['additional']['booking']['slot']['from'])->getTimestamp(); + + $to = Carbon::createFromTimestamp($data['additional']['booking']['slot']['to'])->getTimestamp(); + } + + $result = $this->bookingRepository->getModel() + ->leftJoin('order_items', 'bookings.order_item_id', '=', 'order_items.id') + ->addSelect(DB::raw('SUM(qty_ordered - qty_canceled - qty_refunded) as total_qty_booked')) + ->where('bookings.product_id', $data['product_id']) + ->where(function ($query) use($from, $to) { + $query->where(function ($query) use($from) { + $query->where('bookings.from', '<=', $from)->where('bookings.to', '>=', $from); + }) + ->orWhere(function($query) use($to) { + $query->where('bookings.from', '<=', $to)->where('bookings.to', '>=', $to); + }); + }) + ->first(); + + return ! is_null($result->total_qty_booked) ? $result->total_qty_booked : 0; + } + + /** + * Add booking additional prices to cart item + * + * @param array $products + * @return array + */ + public function addAdditionalPrices($products) + { + $bookingProduct = $this->bookingProductRepository->findOneByField('product_id', $products[0]['product_id']); + + $rentingType = $products[0]['additional']['booking']['renting_type'] ?? $bookingProduct->rental_slot->renting_type; + + if ($rentingType == 'daily') { + $from = Carbon::createFromTimeString($products[0]['additional']['booking']['date_from'] . " 00:00:00"); + $to = Carbon::createFromTimeString($products[0]['additional']['booking']['date_to'] . " 24:00:00"); + + $price = $bookingProduct->rental_slot->daily_price * $to->diffInDays($from); + } else { + $from = Carbon::createFromTimestamp($products[0]['additional']['booking']['slot']['from']); + $to = Carbon::createFromTimestamp($products[0]['additional']['booking']['slot']['to']); + + $price = $bookingProduct->rental_slot->hourly_price * $to->diffInHours($from); + } + + $products[0]['price'] += core()->convertPrice($price); + $products[0]['base_price'] += $price; + $products[0]['total'] += (core()->convertPrice($price) * $products[0]['quantity']); + $products[0]['base_total'] += ($price * $products[0]['quantity']); + + return $products; + } + + /** + * Validate cart item product price + * + * @param \Webkul\Checkout\Contracts\CartItem $item + * @return float + */ + public function validateCartItem($item) + { + $price = $item->product->getTypeInstance()->getFinalPrice(); + + $bookingProduct = $this->bookingProductRepository->findOneByField('product_id', $item->product_id); + + $rentingType = $item->additional['booking']['renting_type'] ?? $bookingProduct->rental_slot->renting_type; + + if ($rentingType == 'daily') { + $from = Carbon::createFromTimeString($item->additional['booking']['date_from'] . " 00:00:00"); + $to = Carbon::createFromTimeString($item->additional['booking']['date_to'] . " 24:00:00"); + + $price += $item->product->getTypeInstance()->getFinalPrice() + $bookingProduct->rental_slot->daily_price * $to->diffInDays($from); + } else { + $from = Carbon::createFromTimestamp($item->additional['booking']['slot']['from']); + $to = Carbon::createFromTimestamp($item->additional['booking']['slot']['to']); + + $price += $bookingProduct->rental_slot->hourly_price * $to->diffInHours($from); + } + + if ($price == $item->base_price) { + return; + } + + $item->base_price = $price; + $item->price = core()->convertPrice($price); + + $item->base_total = $price * $item->quantity; + $item->total = core()->convertPrice($price * $item->quantity); + + $item->save(); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Helpers/TableSlot.php b/packages/Webkul/BookingProduct/src/Helpers/TableSlot.php new file mode 100644 index 000000000..cfa2f0af1 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Helpers/TableSlot.php @@ -0,0 +1,31 @@ +bookingProductRepository->findOneByField('product_id', $cartItem['product_id']); + + $bookedQty = $this->getBookedQuantity($cartItem); + + $requestedQty = $cartItem['quantity']; + + if ($bookingProduct->table_slot->price_type == 'table') { + $requestedQty *= $bookingProduct->table_slot->guest_limit; + + $bookedQty *= $bookingProduct->table_slot->guest_limit; + } + + if ($bookingProduct->qty - $bookedQty < $requestedQty) { + return false; + } + + return true; + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/BookingProductController.php b/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/BookingProductController.php new file mode 100644 index 000000000..d215fa523 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/BookingProductController.php @@ -0,0 +1,65 @@ +bookingProductRepository = $bookingProductRepository; + + $this->bookingHelpers['default'] = $defaultSlotHelper; + + $this->bookingHelpers['appointment'] = $appointmentSlotHelper; + + $this->bookingHelpers['rental'] = $rentalSlotHelper; + + $this->bookingHelpers['event'] = $eventTicketHelper; + + $this->bookingHelpers['table'] = $tableSlotHelper; + } + + /** + * Display the specified resource. + * + * @return \Illuminate\Http\Response + */ + public function index() + { + $bookingProduct = $this->bookingProductRepository->find(request('id')); + + return response()->json([ + 'data' => $this->bookingHelpers[$bookingProduct->type]->getSlotsByDate($bookingProduct, request()->get('date')), + ]); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/Controller.php b/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/Controller.php new file mode 100644 index 000000000..0209a71dc --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Http/Controllers/Shop/Controller.php @@ -0,0 +1,12 @@ + ['web', 'theme', 'locale', 'currency']], function () { + Route::get('/booking-slots/{id}', 'Webkul\BookingProduct\Http\Controllers\Shop\BookingProductController@index')->name('booking_product.slots.index'); +}); \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Listeners/Order.php b/packages/Webkul/BookingProduct/src/Listeners/Order.php new file mode 100644 index 000000000..b73ddec40 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Listeners/Order.php @@ -0,0 +1,36 @@ +bookingRepository = $bookingRepository; + } + + /** + * After sales order creation, add entry to bookings table + * + * @param \Webkul\Sales\Contracts\Order $order + */ + public function afterPlaceOrder($order) + { + $this->bookingRepository->create(['order' => $order]); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Models/Booking.php b/packages/Webkul/BookingProduct/src/Models/Booking.php new file mode 100644 index 000000000..182974986 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Models/Booking.php @@ -0,0 +1,39 @@ +belongsTo(OrderProxy::modelClass()); + } + + /** + * Get the child item record associated with the order item. + */ + public function order_item() + { + return $this->hasOne(OrderItemProxy::modelClass()); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProduct.php b/packages/Webkul/BookingProduct/src/Models/BookingProduct.php new file mode 100644 index 000000000..287247fcf --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Models/BookingProduct.php @@ -0,0 +1,68 @@ + 'datetime', + 'available_to' => 'datetime', + ]; + + /** + * The Product Default Booking that belong to the product booking. + */ + public function default_slot() + { + return $this->hasOne(BookingProductDefaultSlotProxy::modelClass()); + } + + /** + * The Product Appointment Booking that belong to the product booking. + */ + public function appointment_slot() + { + return $this->hasOne(BookingProductAppointmentSlotProxy::modelClass()); + } + + /** + * The Product Event Booking that belong to the product booking. + */ + public function event_tickets() + { + return $this->hasMany(BookingProductEventTicketProxy::modelClass()); + } + + /** + * The Product Rental Booking that belong to the product booking. + */ + public function rental_slot() + { + return $this->hasOne(BookingProductRentalSlotProxy::modelClass()); + } + + /** + * The Product Table Booking that belong to the product booking. + */ + public function table_slot() + { + return $this->hasOne(BookingProductTableSlotProxy::modelClass()); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProductAppointmentSlot.php b/packages/Webkul/BookingProduct/src/Models/BookingProductAppointmentSlot.php new file mode 100644 index 000000000..c87721ab2 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Models/BookingProductAppointmentSlot.php @@ -0,0 +1,21 @@ + 'array']; + + protected $fillable = [ + 'duration', + 'break_time', + 'same_slot_all_days', + 'slots', + 'booking_product_id', + ]; +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProductAppointmentSlotProxy.php b/packages/Webkul/BookingProduct/src/Models/BookingProductAppointmentSlotProxy.php new file mode 100644 index 000000000..a33d0f368 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Models/BookingProductAppointmentSlotProxy.php @@ -0,0 +1,10 @@ + 'array']; + + protected $fillable = [ + 'booking_type', + 'duration', + 'break_time', + 'slots', + 'booking_product_id' + ]; + + /** + * Get the product that owns the attribute value. + */ + public function booking_product() + { + return $this->belongsTo(BookingProductProxy::modelClass()); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProductDefaultSlotProxy.php b/packages/Webkul/BookingProduct/src/Models/BookingProductDefaultSlotProxy.php new file mode 100644 index 000000000..67ee768c8 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Models/BookingProductDefaultSlotProxy.php @@ -0,0 +1,10 @@ + 'array']; + + protected $fillable = [ + 'renting_type', + 'daily_price', + 'hourly_price', + 'same_slot_all_days', + 'slots', + 'booking_product_id', + ]; +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProductRentalSlotProxy.php b/packages/Webkul/BookingProduct/src/Models/BookingProductRentalSlotProxy.php new file mode 100644 index 000000000..1191761bf --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Models/BookingProductRentalSlotProxy.php @@ -0,0 +1,10 @@ + 'array']; + + protected $fillable = [ + 'price_type', + 'guest_limit', + 'duration', + 'break_time', + 'prevent_scheduling_before', + 'same_slot_all_days', + 'slots', + 'booking_product_id', + ]; +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProductTableSlotProxy.php b/packages/Webkul/BookingProduct/src/Models/BookingProductTableSlotProxy.php new file mode 100644 index 000000000..2d5acb217 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Models/BookingProductTableSlotProxy.php @@ -0,0 +1,10 @@ +loadRoutesFrom(__DIR__ . '/../Http/front-routes.php'); + + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'bookingproduct'); + + $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'bookingproduct'); + + $this->publishes([ + __DIR__ . '/../../publishable/assets' => public_path('themes/default/assets'), + ], 'public'); + + $this->app->register(EventServiceProvider::class); + } + + /** + * Register services. + * + * @return void + */ + public function register() + { + $this->mergeConfigFrom( + dirname(__DIR__) . '/Config/product_types.php', 'product_types' + ); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Providers/EventServiceProvider.php b/packages/Webkul/BookingProduct/src/Providers/EventServiceProvider.php new file mode 100644 index 000000000..8b113d8a5 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Providers/EventServiceProvider.php @@ -0,0 +1,23 @@ +addTemplate('bookingproduct::shop.products.view.booking'); + }); + + Event::listen('checkout.order.save.after', 'Webkul\BookingProduct\Listeners\Order@afterPlaceOrder'); + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Providers/ModuleServiceProvider.php b/packages/Webkul/BookingProduct/src/Providers/ModuleServiceProvider.php new file mode 100644 index 000000000..7e121b3bc --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Providers/ModuleServiceProvider.php @@ -0,0 +1,19 @@ +event_tickets()->pluck('id'); + + if (isset($data['tickets'])) { + foreach ($data['tickets'] as $ticketId => $ticketInputs) { + if (Str::contains($ticketId, 'ticket_')) { + $this->create(array_merge([ + 'booking_product_id' => $bookingProduct->id, + ], $ticketInputs)); + } else { + if (is_numeric($index = $previousTicketIds->search($ticketId))) { + $previousTicketIds->forget($index); + } + + $this->update($ticketInputs, $ticketId); + } + } + } + + foreach ($previousTicketIds as $previousTicketId) { + $this->delete($previousTicketId); + } + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Repositories/BookingProductRentalSlotRepository.php b/packages/Webkul/BookingProduct/src/Repositories/BookingProductRentalSlotRepository.php new file mode 100644 index 000000000..ef455bffe --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Repositories/BookingProductRentalSlotRepository.php @@ -0,0 +1,18 @@ +typeRepositories['default'] = $bookingProductDefaultSlotRepository; + + $this->typeRepositories['appointment'] = $bookingProductAppointmentSlotRepository; + + $this->typeRepositories['event'] = $bookingProductEventTicketRepository; + + $this->typeRepositories['rental'] = $bookingProductRentalSlotRepository; + + $this->typeRepositories['table'] = $bookingProductTableSlotRepository; + } + + /** + * Specify Model class name + * + * @return mixed + */ + function model() + { + return 'Webkul\BookingProduct\Contracts\BookingProduct'; + } + + /** + * @param array $data + * @return \Webkul\BookingProduct\Contracts\BookingProduct + */ + public function create(array $data) + { + $bookingProduct = parent::create($data); + + if ($bookingProduct->type == 'event') { + $this->typeRepositories[$data['type']]->saveEventTickets($data, $bookingProduct); + } else { + $this->typeRepositories[$data['type']]->create(array_merge($data, ['booking_product_id' => $bookingProduct->id])); + } + + return $bookingProduct; + } + + /** + * @param array $data + * @param int $id + * @param string $attribute + * @return \Webkul\BookingProduct\Contracts\BookingProduct + */ + public function update(array $data, $id, $attribute = "id") + { + $bookingProduct = parent::update($data, $id, $attribute); + + foreach ($this->typeRepositories as $type => $repository) { + if ($type == $data['type']) { + continue; + } + + $repository->deleteWhere(['booking_product_id' => $id]); + } + + if ($bookingProduct->type == 'event') { + $this->typeRepositories[$data['type']]->saveEventTickets($data, $bookingProduct); + } else { + $bookingProductTypeSlot = $this->typeRepositories[$data['type']]->findOneByField('booking_product_id', $id); + + if (isset($data['slots'])) { + $data['slots'] = $this->formatSlots($data); + + $data['slots'] = $this->validateSlots($data); + } + + if (! $bookingProductTypeSlot) { + $this->typeRepositories[$data['type']]->create(array_merge($data, ['booking_product_id' => $id])); + } else { + $this->typeRepositories[$data['type']]->update($data, $bookingProductTypeSlot->id); + } + } + } + + /** + * @param array $data + * @return array + */ + public function formatSlots($data) + { + if (isset($data['same_slot_all_days']) && ! $data['same_slot_all_days']) { + for ($i = 0; $i < 7; $i++) { + if (! isset($data['slots'][$i])) { + $data['slots'][$i] = []; + } else { + $count = 0; + + $slots = []; + + foreach ($data['slots'][$i] as $slot) { + $slots[] = array_merge($slot, ['id' => $i . '_slot_' . $count]); + + $count++; + } + + $data['slots'][$i] = $slots; + } + } + + ksort($data['slots']); + } + + return $data['slots']; + } + + /** + * @param array $data + * @return array + */ + public function validateSlots($data) + { + if (! isset($data['same_slot_all_days'])) { + return $data; + } + + if (! $data['same_slot_all_days']) { + foreach ($data['slots'] as $day => $slots) { + $data['slots'][$day] = $this->skipOverLappingSlots($slots); + } + } else { + $data['slots'] = $this->skipOverLappingSlots($data['slots']); + } + + return $data['slots']; + } + + /** + * @param array $data + * @return array + */ + public function skipOverLappingSlots($slots) + { + $tempSlots = []; + + foreach ($slots as $key => $timeInterval) { + $from = Carbon::createFromTimeString($timeInterval['from'])->getTimestamp(); + + $to = Carbon::createFromTimeString($timeInterval['to'])->getTimestamp(); + + $isOverLapping = false; + + foreach ($tempSlots as $slot) { + if (($slot['from'] <= $from && $slot['to'] >= $from) + || ($slot['from'] <= $to && $slot['to'] >= $to) + ) { + $isOverLapping = true; + + unset($slots[$key]); + } + } + + if (! $isOverLapping) { + $tempSlots[] = [ + 'from' => $from, + 'to' => $to, + ]; + } + } + + return $slots; + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Repositories/BookingProductTableSlotRepository.php b/packages/Webkul/BookingProduct/src/Repositories/BookingProductTableSlotRepository.php new file mode 100644 index 000000000..3676f0304 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Repositories/BookingProductTableSlotRepository.php @@ -0,0 +1,18 @@ +items()->get() as $item) { + if ($item->type != 'booking') { + continue; + } + + Event::dispatch('booking_product.booking.save.before', $item); + + $from = $to = null; + + if (isset($item->additional['booking']['slot'])) { + if (isset($item->additional['booking']['slot']['from']) && isset($item->additional['booking']['slot']['to'])) { + $from = $item->additional['booking']['slot']['from']; + + $to = $item->additional['booking']['slot']['to']; + } else { + $timestamps = explode('-', $item->additional['booking']['slot']); + + $from = current($timestamps); + + $to = end($timestamps); + } + } elseif (isset($item->additional['booking']['date_from']) && isset($item->additional['booking']['date_to'])) { + $from = Carbon::createFromTimeString($item->additional['booking']['date_from'] . ' 00:00:00')->getTimestamp(); + + $to = Carbon::createFromTimeString($item->additional['booking']['date_to'] . ' 23:59:59')->getTimestamp(); + } + + $booking = parent::create([ + 'qty' => $item->qty_ordered, + 'from' => $from, + 'to' => $to, + 'order_id' => $order->id, + 'order_item_id' => $item->id, + 'product_id' => $item->product_id, + 'booking_product_event_ticket_id' => $item->additional['booking']['ticket_id'] ?? null, + ]); + + Event::dispatch('marketplace.booking.save.after', $booking); + } + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/assets/images/arrow-down.svg b/packages/Webkul/BookingProduct/src/Resources/assets/images/arrow-down.svg new file mode 100644 index 000000000..dd459433e --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/assets/images/arrow-down.svg @@ -0,0 +1,10 @@ + + + + icon-dropdown + Created with Sketch. + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/assets/images/arrow-up.svg b/packages/Webkul/BookingProduct/src/Resources/assets/images/arrow-up.svg new file mode 100644 index 000000000..4ebba93f5 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/assets/images/arrow-up.svg @@ -0,0 +1,10 @@ + + + + icon-dropdown-up + Created with Sketch. + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/assets/images/location.svg b/packages/Webkul/BookingProduct/src/Resources/assets/images/location.svg new file mode 100644 index 000000000..19fd55a0d --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/assets/images/location.svg @@ -0,0 +1,11 @@ + + + + tab/heading/icon/address + Created with Sketch. + + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/assets/images/phone.svg b/packages/Webkul/BookingProduct/src/Resources/assets/images/phone.svg new file mode 100644 index 000000000..e132e7b15 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/assets/images/phone.svg @@ -0,0 +1,18 @@ + + + + icon-menu copy + Created with Sketch. + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/assets/images/slot.svg b/packages/Webkul/BookingProduct/src/Resources/assets/images/slot.svg new file mode 100644 index 000000000..18d00bd75 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/assets/images/slot.svg @@ -0,0 +1,15 @@ + + + + tab/heading/icon/calender + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/assets/sass/default.scss b/packages/Webkul/BookingProduct/src/Resources/assets/sass/default.scss new file mode 100644 index 000000000..eb86e080a --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/assets/sass/default.scss @@ -0,0 +1,230 @@ +@import "icons"; + +.booking-information { + margin-bottom: 15px; + border-top: 1px solid #E8E8E8; + padding-top: 15px; + + .booking-info-row { + padding-left: 32px; + margin-bottom: 20px; + position: relative; + + .icon { + position: absolute; + left: 0; + top: -4px; + } + + .title { + color: #5E5E5E; + display: block; + margin-bottom: 5px; + } + + .value { + display: block; + margin-bottom: 5px; + + .text-danger { + color: #ff5656; + } + } + + .toggle { + color: #0041FF; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + + .icon { + position: relative; + width: 10px; + height: 10px; + margin-left: 5px; + top: 0; + + &.arrow-down-icon { + background-image: url(../images/arrow-down.svg) !important; + } + + &.arrow-up-icon { + background-image: url(../images/arrow-up.svg) !important; + } + } + } + + .days-availability { + table { + margin-top: 10px; + border-collapse: collapse; + + tr { + td { + padding: 5px; + vertical-align: top; + + &:first-child { + padding-left: 0; + } + + &:last-child { + font-size: 14px; + padding-left: 15px; + padding-right: 0; + color: #5E5E5E; + } + + .text-danger { + color: #ff5656; + } + } + } + } + } + } + + .book-slots { + padding-top: 25px; + display: inline-block; + width: 100%; + + h3 { + font-weight: 600; + font-size: 16px; + color: #242424; + margin-top: 0; + } + + label { + color: #3a3a3a; + } + + .control-group, .form-group { + label { + font-size: 16px; + } + + .radio { + display: inline-block; + } + } + + .control-group-container { + width: 100%; + float: left; + + .control-group:not(.quantity), .form-group:not(.quantity) { + width: 50%; + float: left; + + .control, .form-style { + width: 100%; + } + + &.date { + padding-right: 5px; + + &::after { + position: absolute; + top: 14px; + right: 10px; + } + } + + &.slots { + &:first-child { + padding-right: 5px; + } + + &:last-child { + padding-left: 5px; + } + } + } + } + + .ticket-list { + + .ticket-item { + width: 100%; + display: inline-block; + padding: 16px 0; + border-bottom: solid 1px #e8e8e8; + + &:last-child { + border-bottom: 0; + } + + .ticket-info { + width: 50%; + float: left; + + .ticket-name { + color: #242424; + margin-bottom: 12px; + } + + .ticket-price { + color: #5E5E5E; + } + } + + .ticket-quantity { + width: 50%; + display: inline-block; + text-align: right; + + .control-group, .form-group { + margin: 0; + + &.quantity { + max-width: initial; + width: auto; + text-align: center; + margin-bottom: 0; + border-top: 0; + padding-top: 0; + + label { + display: none; + } + } + } + } + + p { + color: #242424; + margin-bottom: 0; + font-weight: 400; + } + } + } + + .ticket-total { + font-size: 16px; + font-weight: 600; + color: #242424; + padding-top: 16px; + border-top: solid 1px #e8e8e8; + + > div { + margin-bottom: 12px; + + &:last-child { + margin-bottom: 0; + } + + p { + color: #242424; + font-weight: 400; + margin-top: 4px; + } + } + } + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/assets/sass/icons.scss b/packages/Webkul/BookingProduct/src/Resources/assets/sass/icons.scss new file mode 100644 index 000000000..77c4d1be1 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/assets/sass/icons.scss @@ -0,0 +1,17 @@ +.bp-location-icon { + background-image: url("../images/location.svg"); + width: 32px; + height: 32px; +} + +.bp-slot-icon { + background-image: url("../images/slot.svg"); + width: 32px; + height: 32px; +} + +.bp-phone-icon { + background-image: url("../images/phone.svg"); + width: 32px; + height: 32px; +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/assets/sass/velocity.scss b/packages/Webkul/BookingProduct/src/Resources/assets/sass/velocity.scss new file mode 100644 index 000000000..28be20667 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/assets/sass/velocity.scss @@ -0,0 +1,226 @@ +@import "icons"; + +.booking-information { + margin-bottom: 15px; + + .booking-info-row { + padding-left: 32px; + margin-bottom: 20px; + position: relative; + + .icon { + position: absolute; + left: 0; + top: -4px; + } + + .title { + color: #5E5E5E; + display: block; + margin-bottom: 5px; + } + + .value { + display: block; + margin-bottom: 5px; + + .text-danger { + color: #ff5656; + } + } + + .toggle { + color: #0041FF; + cursor: pointer; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + + .icon { + position: relative; + width: 10px; + height: 10px; + margin-left: 5px; + top: 0; + + &.arrow-down-icon { + background-image: url(../images/arrow-down.svg) !important; + } + + &.arrow-up-icon { + background-image: url(../images/arrow-up.svg) !important; + } + } + } + + .days-availability { + table { + margin-top: 10px; + border-collapse: collapse; + + tr { + td { + padding: 5px; + vertical-align: top; + + &:first-child { + padding-left: 0; + } + + &:last-child { + font-size: 14px; + padding-left: 15px; + padding-right: 0; + color: #5E5E5E; + } + + .text-danger { + color: #ff5656; + } + } + } + } + } + } + + .book-slots { + display: inline-block; + width: 100%; + + h3 { + font-weight: 600; + font-size: 16px; + color: #242424; + margin-top: 0; + } + + label { + color: #3a3a3a; + } + + .control-group, .form-group { + label { + font-size: 16px; + } + + .radio { + display: inline-block; + } + } + + .control-group-container { + width: 100%; + float: left; + + .control-group:not(.quantity), .form-group:not(.quantity) { + width: 50%; + float: left; + + .control, .form-style { + width: 100%; + } + + &.date { + padding-right: 5px; + + &::after { + position: absolute; + top: 14px; + right: 10px; + } + } + + &.slots { + &:first-child { + padding-right: 5px; + } + + &:last-child { + padding-left: 5px; + } + } + } + } + + .ticket-list { + + .ticket-item { + width: 100%; + display: inline-block; + padding: 16px 0; + border-bottom: solid 1px #e8e8e8; + + &:last-child { + border-bottom: 0; + } + + .ticket-info { + width: 50%; + float: left; + + .ticket-name { + color: #242424; + margin-bottom: 12px; + } + + .ticket-price { + color: #5E5E5E; + } + } + + .ticket-quantity { + width: 50%; + display: inline-block; + text-align: right; + + .control-group, .form-group { + margin: 0; + + &.quantity { + max-width: initial; + width: auto; + text-align: center; + margin-bottom: 0; + border-top: 0; + padding-top: 0; + + label { + display: none; + } + } + } + } + + p { + color: #242424; + margin-bottom: 0; + font-weight: 400; + } + } + } + + .ticket-total { + font-size: 16px; + font-weight: 600; + color: #242424; + padding-top: 16px; + + > div { + margin-bottom: 12px; + + &:last-child { + margin-bottom: 0; + } + + p { + color: #242424; + font-weight: 400; + margin-top: 4px; + } + } + } + } +} \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/lang/en/app.php b/packages/Webkul/BookingProduct/src/Resources/lang/en/app.php new file mode 100644 index 000000000..aed75c8a6 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/lang/en/app.php @@ -0,0 +1,124 @@ + [ + 'catalog' => [ + 'products' => [ + 'booking' => 'Booking Information', + 'booking-type' => 'Booking Type', + 'default' => 'Default', + 'appointment-booking' => 'Appointment Booking', + 'event-booking' => 'Event Booking', + 'rental-booking' => 'Rental Booking', + 'table-booking' => 'Table Booking', + 'slot-duration' => 'Slot Duration (Mins)', + 'break-time' => 'Break Time b/w Slots (Mins)', + 'available-every-week' => 'Available Every Week', + 'yes' => 'Yes', + 'no' => 'No', + 'available-from' => 'Available From', + 'available-to' => 'Available To', + 'same-slot-all-days' => 'Same Slot All Days', + 'slot-has-quantity' => 'Slot has Quantity', + 'slots' => 'Slots', + 'from' => 'From', + 'to' => 'To', + 'qty' => 'Qty', + 'add-slot' => 'Add Slot', + 'sunday' => 'Sunday', + 'monday' => 'Monday', + 'tuesday' => 'Tuesday', + 'wednesday' => 'Wednesday', + 'thursday' => 'Thursday', + 'friday' => 'Friday', + 'saturday' => 'Saturday', + 'renting-type' => 'Renting Type', + 'daily' => 'Daily Basis', + 'hourly' => 'Hourly Basis', + 'daily-hourly' => 'Both (Daily and Hourly Basis)', + 'daily-price' => 'Daily Price', + 'hourly-price' => 'Hourly Price', + 'location' => 'Location', + 'show-location' => 'Show Location', + 'event-start-date' => 'Event Start Date', + 'event-end-date' => 'Event End Date', + 'tickets' => 'Tickets', + 'add-ticket' => 'Add Ticket', + 'name' => 'Name', + 'price' => 'Price', + 'quantity' => 'Quantity', + 'description' => 'Description', + 'charged-per' => 'Charged Per', + 'guest' => 'Guest', + 'table' => 'Table', + 'prevent-scheduling-before' => 'Prevent Scheduling Before', + 'guest-limit' => 'Guest Limit Per Table', + 'guest-capacity' => 'Guest Capacity', + 'type' => 'Type', + 'many-bookings-for-one-day' => 'Many Bookings for One Day', + 'one-booking-for-many-days' => 'One Booking for Many Days', + 'day' => 'Day', + 'status' => 'Status', + 'open' => 'Open', + 'close' => 'Close' + ] + ] + ], + + 'shop' => [ + 'products' => [ + 'location' => 'Location', + 'contact' => 'Contact', + 'email' => 'Email', + 'slot-duration' => 'Slot Duration', + 'slot-duration-in-minutes' => ':minutes Minutes', + 'today-availability' => 'Today Availability', + 'sunday' => 'Sunday', + 'monday' => 'Monday', + 'tuesday' => 'Tuesday', + 'wednesday' => 'Wednesday', + 'thursday' => 'Thursday', + 'friday' => 'Friday', + 'saturday' => 'Saturday', + 'closed' => 'Closed', + 'book-an-appointment' => 'Book an Appointment', + 'date' => 'Date', + 'slot' => 'Slot', + 'rent-an-item' => 'Rent an Item', + 'choose-rent-option' => 'Choose Rent Option', + 'daily-basis' => 'Daily Basis', + 'hourly-basis' => 'Hourly Basis', + 'select-time-slot'=> 'Select time slot', + 'select-slot' => 'Select Slot', + 'select-date' => 'Select date', + 'select-rent-time' => 'Select Rent Time', + 'from' => 'From', + 'to' => 'To', + 'book-a-table' => 'Book a Table', + 'special-notes' => 'Special Request/Notes', + 'event-on' => 'Event On', + 'book-your-ticket' => 'Book Your Ticket', + 'per-ticket-price' => ':price Per Ticket', + 'number-of-tickets' => 'Number of Tickets', + 'total-tickets' => 'Total Tickets', + 'base-price' => 'Base Price', + 'total-price' => 'Total Price', + 'base-price-info' => '(This will be apply to each type of ticket for each quantity)' + ], + + 'cart' => [ + 'renting_type' => 'Rent Type', + 'daily' => 'Daily', + 'hourly' => 'Hourly', + 'event-ticket' => 'Event Ticket', + 'event-from' => 'Event From', + 'event-till' => 'Event Till', + 'rent-type' => 'Rent Type', + 'rent-from' => 'Rent From', + 'rent-till' => 'Rent Till', + 'booking-from' => 'Booking From', + 'booking-till' => 'Booking Till', + 'special-note' => 'Special Request/Notes', + ] + ] +]; \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking.blade.php new file mode 100644 index 000000000..1e45713f9 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking.blade.php @@ -0,0 +1,138 @@ +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.before', ['product' => $product]) !!} + + +
+ + + +
+
+ +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.after', ['product' => $product]) !!} + +@push('scripts') + findOneByField('product_id', $product->id) ?> + + @parent + + + + + + @include ('bookingproduct::admin.catalog.products.accordians.booking.slots') + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/appointment.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/appointment.blade.php new file mode 100644 index 000000000..c44deb21a --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/appointment.blade.php @@ -0,0 +1,78 @@ +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.appointment.before', ['product' => $product]) !!} + + + +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.appointment.after', ['product' => $product]) !!} + +@push('scripts') + @parent + + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/default.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/default.blade.php new file mode 100644 index 000000000..996603c31 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/default.blade.php @@ -0,0 +1,287 @@ +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.table.before', ['product' => $product]) !!} + + + +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.table.after', ['product' => $product]) !!} + + +@section('css') + +@stop + +@push('scripts') + @parent + + + + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/event.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/event.blade.php new file mode 100644 index 000000000..061c8e92d --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/event.blade.php @@ -0,0 +1,169 @@ +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.event.before', ['product' => $product]) !!} + + + +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.event.after', ['product' => $product]) !!} + +@push('scripts') + @parent + + + + + + + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/rental.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/rental.blade.php new file mode 100644 index 000000000..00731feec --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/rental.blade.php @@ -0,0 +1,98 @@ +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.rental.before', ['product' => $product]) !!} + + + +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.rental.after', ['product' => $product]) !!} + +@push('scripts') + @parent + + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/slots.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/slots.blade.php new file mode 100644 index 000000000..f3520241f --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/slots.blade.php @@ -0,0 +1,195 @@ + + + + + \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/table.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/table.blade.php new file mode 100644 index 000000000..947cad191 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/admin/catalog/products/accordians/booking/table.blade.php @@ -0,0 +1,119 @@ +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.table.before', ['product' => $product]) !!} + + + +{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.booking.table.after', ['product' => $product]) !!} + +@push('scripts') + @parent + + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking.blade.php new file mode 100644 index 000000000..14d805431 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking.blade.php @@ -0,0 +1,48 @@ +@if ($product->type == 'booking') + + @if ($bookingProduct = app('\Webkul\BookingProduct\Repositories\BookingProductRepository')->findOneByField('product_id', $product->product_id)) + + @push('css') + + @endpush + + + + @push('scripts') + + + + + + @endpush + + @endif + +@endif \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/appointment.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/appointment.blade.php new file mode 100644 index 000000000..b67be37ad --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/appointment.blade.php @@ -0,0 +1,55 @@ +
+ + + {{ __('bookingproduct::app.shop.products.slot-duration') }} : + + {{ __('bookingproduct::app.shop.products.slot-duration-in-minutes', ['minutes' => $bookingProduct->appointment_slot->duration]) }} + +
+ +@inject ('bookingSlotHelper', 'Webkul\BookingProduct\Helpers\AppointmentSlot') + +
+ + + {{ __('bookingproduct::app.shop.products.today-availability') }} + + + + + {!! $bookingSlotHelper->getTodaySlotsHtml($bookingProduct) !!} + + + +
+ Show for all days + + +
+ +
+ + + + @foreach ($bookingSlotHelper->getWeekSlotDurations($bookingProduct) as $day) + + + + + + @endforeach + +
{{ $day['name'] }} + @if ($day['slots'] && count($day['slots'])) + @foreach ($day['slots'] as $slot) + {{ $slot['from'] . ' - ' . $slot['to'] }}
+ @endforeach + @else + {{ __('bookingproduct::app.shop.products.closed') }} + @endif +
+ +
+
+ +@include ('bookingproduct::shop.products.view.booking.slots', ['bookingProduct' => $bookingProduct]) \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/default.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/default.blade.php new file mode 100644 index 000000000..32bc26e52 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/default.blade.php @@ -0,0 +1,10 @@ +
+ + + {{ __('bookingproduct::app.shop.products.slot-duration') }} : + + {{ __('bookingproduct::app.shop.products.slot-duration-in-minutes', ['minutes' => $bookingProduct->default_slot->duration]) }} + +
+ +@include ('bookingproduct::shop.products.view.booking.slots', ['bookingProduct' => $bookingProduct]) \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/event.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/event.blade.php new file mode 100644 index 000000000..a50adda53 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/event.blade.php @@ -0,0 +1,65 @@ +@inject ('bookingSlotHelper', 'Webkul\BookingProduct\Helpers\EventTicket') + +
+ + + {{ __('bookingproduct::app.shop.products.event-on') }} + + + {!! $bookingSlotHelper->getEventDate($bookingProduct) !!} + +
+ + + +@push('scripts') + + + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/rental.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/rental.blade.php new file mode 100644 index 000000000..8de8a1d53 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/rental.blade.php @@ -0,0 +1,153 @@ + + +@push('scripts') + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/slots.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/slots.blade.php new file mode 100644 index 000000000..0a1a3c068 --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/slots.blade.php @@ -0,0 +1,57 @@ + + +@push('scripts') + + + +@endpush \ No newline at end of file diff --git a/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/table.blade.php b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/table.blade.php new file mode 100644 index 000000000..78300bd6f --- /dev/null +++ b/packages/Webkul/BookingProduct/src/Resources/views/shop/default/products/view/booking/table.blade.php @@ -0,0 +1,63 @@ +
+ + + {{ __('bookingproduct::app.shop.products.slot-duration') }} : + + {{ __('bookingproduct::app.shop.products.slot-duration-in-minutes', ['minutes' => $bookingProduct->table_slot->duration]) }} + +
+ +@inject ('bookingSlotHelper', 'Webkul\BookingProduct\Helpers\TableSlot') + +
+ + + {{ __('bookingproduct::app.shop.products.today-availability') }} + + + + + {!! $bookingSlotHelper->getTodaySlotsHtml($bookingProduct) !!} + + + +
+ Show for all days + + +
+ +
+ + + + @foreach ($bookingSlotHelper->getWeekSlotDurations($bookingProduct) as $day) + + + + + + @endforeach + +
{{ $day['name'] }} + @if ($day['slots'] && count($day['slots'])) + @foreach ($day['slots'] as $slot) + {{ $slot['from'] . ' - ' . $slot['to'] }}
+ @endforeach + @else + {{ __('bookingproduct::app.shop.products.closed') }} + @endif +
+ +
+
+ +@include ('bookingproduct::shop.products.view.booking.slots', [ + 'bookingProduct' => $bookingProduct, + 'title' => __('bookingproduct::app.shop.products.book-a-table') + ]) + +
+ +