From 05be7a070aef26280a6597393e3b2216c2129482 Mon Sep 17 00:00:00 2001 From: Jitendra Singh Date: Thu, 27 Feb 2020 13:33:03 +0530 Subject: [PATCH] Improved code style --- .../Controllers/Shop/AddressController.php | 30 ++--- .../Controllers/Shop/CategoryController.php | 4 +- .../Controllers/Shop/CheckoutController.php | 6 +- .../Controllers/Shop/CustomerController.php | 4 +- .../Shop/ForgotPasswordController.php | 8 +- .../Controllers/Shop/ProductController.php | 12 +- .../Controllers/Shop/ResourceController.php | 8 +- .../Controllers/Shop/ReviewController.php | 6 +- .../Controllers/Shop/SessionController.php | 14 +-- .../Controllers/Shop/WishlistController.php | 42 +++---- .../Admin/src/DataGrids/AddressDataGrid.php | 3 +- .../Admin/src/DataGrids/CMSPageDataGrid.php | 2 +- .../Admin/src/DataGrids/CartRuleDataGrid.php | 2 +- .../Admin/src/DataGrids/CategoryDataGrid.php | 2 +- .../Admin/src/DataGrids/OrderDataGrid.php | 4 +- .../src/DataGrids/OrderRefundDataGrid.php | 2 +- .../src/DataGrids/OrderShipmentsDataGrid.php | 2 +- .../Webkul/Admin/src/Exceptions/Handler.php | 8 +- .../src/Mail/CancelOrderNotification.php | 4 +- .../Admin/src/Mail/NewAdminNotification.php | 4 +- .../src/Mail/NewCustomerNotification.php | 4 +- .../Mail/NewInventorySourceNotification.php | 4 +- .../Admin/src/Mail/NewInvoiceNotification.php | 4 +- .../Admin/src/Mail/NewOrderNotification.php | 4 +- .../Admin/src/Mail/NewRefundNotification.php | 4 +- .../src/Mail/NewShipmentNotification.php | 4 +- .../Webkul/Attribute/src/Models/Attribute.php | 18 ++- .../Attribute/src/Models/AttributeGroup.php | 4 +- .../Attribute/src/Models/AttributeOption.php | 3 +- .../AttributeOptionRepository.php | 4 +- .../src/Repositories/AttributeRepository.php | 8 +- .../BookingProduct/src/Helpers/Booking.php | 35 +++--- .../src/Helpers/DefaultSlot.php | 20 ++-- .../src/Helpers/EventTicket.php | 10 +- .../BookingProduct/src/Helpers/RentalSlot.php | 36 +++--- .../BookingProduct/src/Models/Booking.php | 10 +- .../src/Models/BookingProduct.php | 11 +- .../src/Models/BookingProductTableSlot.php | 12 +- .../BookingProductEventTicketRepository.php | 4 +- .../src/Repositories/BookingRepository.php | 16 +-- .../BookingProduct/src/Type/Booking.php | 16 +-- packages/Webkul/CMS/src/Models/CmsPage.php | 10 +- .../CMS/src/Models/CmsPageTranslation.php | 11 +- .../Webkul/CartRule/src/Helpers/CartRule.php | 24 ++-- .../Webkul/CartRule/src/Listeners/Order.php | 28 ++--- .../CartRule/src/Models/CartRuleCoupon.php | 11 +- .../Repositories/CartRuleCouponRepository.php | 14 +-- .../src/Repositories/CartRuleRepository.php | 52 ++++----- .../src/Helpers/CatalogRuleIndex.php | 10 +- .../src/Helpers/CatalogRuleProduct.php | 26 ++--- .../src/Helpers/CatalogRuleProductPrice.php | 10 +- .../CatalogRule/src/Models/CatalogRule.php | 14 ++- .../src/Models/CatalogRuleProduct.php | 13 ++- .../src/Models/CatalogRuleProductPrice.php | 10 +- .../Database/Seeders/CategoryTableSeeder.php | 24 +++- .../Webkul/Category/src/Models/Category.php | 10 +- .../src/Repositories/CategoryRepository.php | 12 +- packages/Webkul/Checkout/src/Cart.php | 50 ++++---- .../Database/Factories/CartAddressFactory.php | 1 + .../Checkout/src/Models/CartShippingRate.php | 12 +- packages/Webkul/Core/src/Core.php | 22 ++-- .../Database/Seeders/ChannelTableSeeder.php | 40 +++---- .../Database/Seeders/CurrencyTableSeeder.php | 19 +-- .../Database/Seeders/LocalesTableSeeder.php | 3 +- .../Core/src/Eloquent/TranslatableModel.php | 4 +- .../Core/src/Helpers/Laravel5Helper.php | 4 +- .../Controllers/ExchangeRateController.php | 12 +- .../src/Http/Controllers/LocaleController.php | 4 +- .../src/Http/Controllers/SliderController.php | 5 +- .../Controllers/SubscriptionController.php | 6 +- packages/Webkul/Core/src/Models/Channel.php | 14 ++- .../Webkul/Core/src/Models/CoreConfig.php | 5 +- .../Core/src/Models/CurrencyExchangeRate.php | 3 +- packages/Webkul/Core/src/Models/Locale.php | 4 +- packages/Webkul/Core/src/Models/Slider.php | 5 +- .../Core/src/Models/SubscribersList.php | 5 +- .../src/Repositories/CoreConfigRepository.php | 21 ++-- .../src/Repositories/CurrencyRepository.php | 1 - .../Controllers/RegistrationController.php | 1 + .../Http/Controllers/WishlistController.php | 8 +- .../Http/Middleware/RedirectIfNotCustomer.php | 1 + .../Customer/src/Mail/RegistrationEmail.php | 4 +- .../Customer/src/Mail/VerificationEmail.php | 9 +- .../Webkul/Customer/src/Models/Customer.php | 41 +++++-- .../Webkul/Customer/src/Models/Wishlist.php | 10 +- .../Notifications/CustomerResetPassword.php | 7 +- .../Controllers/InventorySourceController.php | 1 + packages/Webkul/Payment/src/Payment.php | 8 +- packages/Webkul/Paypal/src/Payment/Paypal.php | 6 +- .../src/Console/Commands/PriceUpdate.php | 14 +-- .../Webkul/Product/src/Helpers/Review.php | 8 +- .../Webkul/Product/src/Helpers/Toolbar.php | 14 +-- .../Http/Controllers/ProductController.php | 9 +- .../src/Http/Controllers/ReviewController.php | 10 +- .../Product/src/Http/Requests/ProductForm.php | 8 +- .../Product/src/Listeners/ProductFlat.php | 11 +- .../Webkul/Product/src/Models/Product.php | 8 +- .../src/Models/ProductBundleOptionProduct.php | 9 +- .../src/Models/ProductDownloadableLink.php | 16 ++- .../Product/src/Models/ProductReview.php | 10 +- .../ProductBundleOptionProductRepository.php | 4 +- .../ProductBundleOptionRepository.php | 4 +- .../ProductDownloadableLinkRepository.php | 4 +- .../ProductDownloadableSampleRepository.php | 4 +- .../Repositories/ProductFlatRepository.php | 28 +++-- .../ProductGroupedProductRepository.php | 4 +- .../Repositories/ProductImageRepository.php | 6 +- .../ProductInventoryRepository.php | 18 +-- .../src/Repositories/ProductRepository.php | 92 +++++++-------- .../Webkul/Product/src/Type/AbstractType.php | 20 ++-- packages/Webkul/Product/src/Type/Bundle.php | 21 ++-- .../Webkul/Product/src/Type/Configurable.php | 95 +++++++-------- packages/Webkul/Product/src/Type/Grouped.php | 6 +- .../Webkul/Rule/src/Helpers/Validator.php | 11 +- .../src/Models/DownloadableLinkPurchased.php | 15 ++- .../Repositories/InvoiceItemRepository.php | 12 +- .../src/Repositories/InvoiceRepository.php | 110 +++++++++--------- .../src/Repositories/OrderItemRepository.php | 20 ++-- .../src/Repositories/OrderRepository.php | 8 +- .../src/Repositories/RefundItemRepository.php | 18 +-- .../src/Repositories/RefundRepository.php | 100 ++++++++-------- .../Repositories/ShipmentItemRepository.php | 10 +- .../src/Repositories/ShipmentRepository.php | 72 ++++++------ packages/Webkul/Shipping/src/Shipping.php | 8 +- .../Webkul/Shop/src/Exceptions/Handler.php | 8 +- .../DownloadableProductController.php | 13 ++- .../Http/Controllers/OnepageController.php | 24 ++-- .../Shop/src/Mail/SubscriptionEmail.php | 9 +- packages/Webkul/Tax/src/Helpers/Tax.php | 10 +- .../Webkul/Tax/src/Models/TaxCategory.php | 8 +- packages/Webkul/Tax/src/Models/TaxMap.php | 3 +- packages/Webkul/Tax/src/Models/TaxRate.php | 13 ++- .../src/Exceptions/ThemeAlreadyExists.php | 7 +- .../Theme/src/Exceptions/ThemeNotFound.php | 7 +- packages/Webkul/Ui/src/DataGrid/DataGrid.php | 1 - .../Database/Seeders/AdminsTableSeeder.php | 20 ++-- .../src/Database/Seeders/RolesTableSeeder.php | 10 +- packages/Webkul/User/src/Models/Admin.php | 11 +- packages/Webkul/User/src/Models/Role.php | 5 +- .../Webkul/Velocity/src/Helpers/Helper.php | 17 +-- .../Controllers/Admin/ContentController.php | 6 +- .../Http/Controllers/Shop/ShopController.php | 6 +- .../Webkul/Velocity/src/Models/Content.php | 11 +- .../src/Models/ContentTranslation.php | 11 +- .../Velocity/src/Models/OrderBrands.php | 3 +- .../Product/ProductRepository.php | 68 +++++------ 146 files changed, 1211 insertions(+), 880 deletions(-) diff --git a/packages/Webkul/API/Http/Controllers/Shop/AddressController.php b/packages/Webkul/API/Http/Controllers/Shop/AddressController.php index 705d716ad..5e438c802 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/AddressController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/AddressController.php @@ -78,25 +78,25 @@ class AddressController extends Controller $customer = auth($this->guard)->user(); request()->merge([ - 'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))), + '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) + ]); } /** @@ -112,18 +112,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/CategoryController.php b/packages/Webkul/API/Http/Controllers/Shop/CategoryController.php index 19a5b2390..9b0045bbe 100755 --- a/packages/Webkul/API/Http/Controllers/Shop/CategoryController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CategoryController.php @@ -40,7 +40,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 d4d51d32b..145a37c81 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CheckoutController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CheckoutController.php @@ -192,9 +192,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/CustomerController.php b/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php index 0a75d32f9..bd5d0e4f2 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/CustomerController.php @@ -85,7 +85,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..4828c4950 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ForgotPasswordController.php @@ -30,13 +30,13 @@ class ForgotPasswordController extends Controller 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..7664c86b4 100755 --- a/packages/Webkul/API/Http/Controllers/Shop/ProductController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ProductController.php @@ -51,8 +51,8 @@ class ProductController extends Controller public function get($id) { return new ProductResource( - $this->productRepository->findOrFail($id) - ); + $this->productRepository->findOrFail($id) + ); } /** @@ -63,8 +63,8 @@ class ProductController extends Controller 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)) + ]); } /** @@ -75,7 +75,7 @@ class ProductController extends Controller 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..1ab9c6ad6 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ResourceController.php @@ -92,8 +92,8 @@ class ResourceController extends Controller public function get($id) { return new $this->_config['resource']( - $this->repository->findOrFail($id) - ); + $this->repository->findOrFail($id) + ); } /** @@ -108,7 +108,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 3c7f3086b..01f3e08e9 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/ReviewController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/ReviewController.php @@ -68,8 +68,8 @@ class ReviewController extends Controller $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 1d22aa332..8ac8c818c 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/SessionController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/SessionController.php @@ -71,10 +71,10 @@ class SessionController extends Controller $customer = auth($this->guard)->user(); return response()->json([ - 'token' => $jwtToken, - 'message' => 'Logged in successfully.', - 'data' => new CustomerResource($customer) - ]); + 'token' => $jwtToken, + 'message' => 'Logged in successfully.', + 'data' => new CustomerResource($customer) + ]); } /** @@ -124,9 +124,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 07cd54e41..bfcd6e483 100644 --- a/packages/Webkul/API/Http/Controllers/Shop/WishlistController.php +++ b/packages/Webkul/API/Http/Controllers/Shop/WishlistController.php @@ -64,29 +64,29 @@ 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 + ]); + + if (! $wishlistItem) { + $wishlistItem = $this->wishlistRepository->create([ 'channel_id' => core()->getCurrentChannel()->id, 'product_id' => $id, 'customer_id' => $customer->id ]); - if (! $wishlistItem) { - $wishlistItem = $this->wishlistRepository->create([ - 'channel_id' => core()->getCurrentChannel()->id, - 'product_id' => $id, - 'customer_id' => $customer->id - ]); - return response()->json([ - 'data' => new WishlistResource($wishlistItem), - 'message' => trans('customer::app.wishlist.success') - ]); + '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.' + ]); } } @@ -102,8 +102,8 @@ class WishlistController extends Controller 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); @@ -114,14 +114,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/Admin/src/DataGrids/AddressDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php index 4c438d244..6292d7259 100644 --- a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php @@ -59,8 +59,7 @@ class AddressDataGrid extends DataGrid ->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'); diff --git a/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php index d039ecaf8..b50ad0b0e 100644 --- a/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CMSPageDataGrid.php @@ -23,7 +23,7 @@ class CMSPageDataGrid extends DataGrid ->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()); + ->where('cms_page_translations.locale', app()->getLocale()); }); $this->addFilter('id', 'cms_pages.id'); diff --git a/packages/Webkul/Admin/src/DataGrids/CartRuleDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CartRuleDataGrid.php index db0907430..9b05632e2 100644 --- a/packages/Webkul/Admin/src/DataGrids/CartRuleDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CartRuleDataGrid.php @@ -22,7 +22,7 @@ class CartRuleDataGrid extends DataGrid $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); + ->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'); diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 273423be0..cfac52d06 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -24,7 +24,7 @@ class CategoryDataGrid extends DataGrid 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()); + ->where('ct.locale', app()->getLocale()); }) ->leftJoin('product_categories as pc', 'cat.id', '=', 'pc.category_id') ->groupBy('cat.id'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index 99d8457d3..fa4d0f9bb 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -22,11 +22,11 @@ class OrderDataGrid extends DataGrid $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'); + ->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'); + ->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')) diff --git a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php index 2ef046f55..c3afffa28 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php @@ -24,7 +24,7 @@ class OrderRefundDataGrid extends DataGrid ->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'); + ->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')); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index adcb561ac..9063aeb79 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -22,7 +22,7 @@ class OrderShipmentsDataGrid extends DataGrid $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'); + ->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') diff --git a/packages/Webkul/Admin/src/Exceptions/Handler.php b/packages/Webkul/Admin/src/Exceptions/Handler.php index 4ae3e60e0..a3e346d76 100755 --- a/packages/Webkul/Admin/src/Exceptions/Handler.php +++ b/packages/Webkul/Admin/src/Exceptions/Handler.php @@ -67,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/Mail/CancelOrderNotification.php b/packages/Webkul/Admin/src/Mail/CancelOrderNotification.php index 92c2d4573..5b20bc946 100644 --- a/packages/Webkul/Admin/src/Mail/CancelOrderNotification.php +++ b/packages/Webkul/Admin/src/Mail/CancelOrderNotification.php @@ -25,7 +25,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 f9ad3f693..b64e058b5 100644 --- a/packages/Webkul/Admin/src/Mail/NewAdminNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewAdminNotification.php @@ -42,7 +42,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..8615c144f 100644 --- a/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewCustomerNotification.php @@ -51,7 +51,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 d6cd994cc..c2fe37427 100644 --- a/packages/Webkul/Admin/src/Mail/NewInventorySourceNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewInventorySourceNotification.php @@ -47,7 +47,7 @@ class NewInventorySourceNotification extends Mailable $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..f8d0af641 100755 --- a/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewInvoiceNotification.php @@ -45,7 +45,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..77ca3bd58 100755 --- a/packages/Webkul/Admin/src/Mail/NewOrderNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewOrderNotification.php @@ -42,7 +42,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..e4fda215d 100644 --- a/packages/Webkul/Admin/src/Mail/NewRefundNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewRefundNotification.php @@ -45,7 +45,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..c8287c0ef 100755 --- a/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php +++ b/packages/Webkul/Admin/src/Mail/NewShipmentNotification.php @@ -45,7 +45,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/Attribute/src/Models/Attribute.php b/packages/Webkul/Attribute/src/Models/Attribute.php index 244d94497..f55bd8ab1 100755 --- a/packages/Webkul/Attribute/src/Models/Attribute.php +++ b/packages/Webkul/Attribute/src/Models/Attribute.php @@ -9,7 +9,23 @@ 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']; + 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', + ]; // 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..096924aa5 100755 --- a/packages/Webkul/Attribute/src/Models/AttributeOption.php +++ b/packages/Webkul/Attribute/src/Models/AttributeOption.php @@ -27,8 +27,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/Repositories/AttributeOptionRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeOptionRepository.php index d8a6c72fb..099fe2635 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeOptionRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeOptionRepository.php @@ -64,8 +64,8 @@ class AttributeOptionRepository extends Repository 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 de45cfd38..41ac27323 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php @@ -68,8 +68,8 @@ class AttributeRepository extends Repository 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)); } } @@ -101,8 +101,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); diff --git a/packages/Webkul/BookingProduct/src/Helpers/Booking.php b/packages/Webkul/BookingProduct/src/Helpers/Booking.php index d52b35170..6094f41cc 100644 --- a/packages/Webkul/BookingProduct/src/Helpers/Booking.php +++ b/packages/Webkul/BookingProduct/src/Helpers/Booking.php @@ -272,8 +272,8 @@ class Booking : Carbon::createFromTimeString('2080-01-01 00:00:00'); $timeDurations = $bookingProductSlot->same_slot_all_days - ? $bookingProductSlot->slots - : ($bookingProductSlot->slots[$requestedDate->format('w')] ?? []); + ? $bookingProductSlot->slots + : ($bookingProductSlot->slots[$requestedDate->format('w')] ?? []); $slots = []; @@ -315,11 +315,11 @@ class Booking if ($qty && $currentTime <= $from) { $slots[] = [ - 'from' => $from->format('h:i A'), - 'to' => $to->format('h:i A'), - 'timestamp' => $from->getTimestamp() . '-' . $to->getTimestamp(), - 'qty' => $qty, - ]; + 'from' => $from->format('h:i A'), + 'to' => $to->format('h:i A'), + 'timestamp' => $from->getTimestamp() . '-' . $to->getTimestamp(), + 'qty' => $qty, + ]; } } else { break; @@ -371,12 +371,12 @@ class Booking $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(); + ->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; } @@ -412,7 +412,8 @@ class Booking 'attribute_name' => 'Rent Till', 'option_id' => 0, 'option_label' => Carbon::createFromTimeString($bookingProduct->available_to)->format('d F, Y'), - ]]; + ] + ]; break; @@ -442,7 +443,8 @@ class Booking 'attribute_name' => 'Rent Till', 'option_id' => 0, 'option_label' => $to, - ]]; + ] + ]; break; @@ -458,7 +460,8 @@ class Booking 'attribute_name' => 'Booking Till', 'option_id' => 0, 'option_label' => Carbon::createFromTimestamp($timestamps[1])->format('d F, Y h:i A'), - ]]; + ] + ]; break; } diff --git a/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php b/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php index 81d2bc095..a33a5184d 100644 --- a/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php +++ b/packages/Webkul/BookingProduct/src/Helpers/DefaultSlot.php @@ -37,12 +37,12 @@ class DefaultSlot extends Booking $currentTime = Carbon::now(); $availableFrom = ! $bookingProduct->available_from && $bookingProduct->available_from - ? Carbon::createFromTimeString($bookingProduct->available_from) - : clone $currentTime; + ? 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'); + ? Carbon::createFromTimeString($bookingProduct->available_to) + : Carbon::createFromTimeString('2080-01-01 00:00:00'); if ($requestedDate < $currentTime || $requestedDate < $availableFrom @@ -53,8 +53,8 @@ class DefaultSlot extends Booking $slots = []; return $bookingProductSlot->booking_type == 'one' - ? $this->getOneBookingForManyDaysSlots($bookingProductSlot, $requestedDate) - : $this->getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate); + ? $this->getOneBookingForManyDaysSlots($bookingProductSlot, $requestedDate) + : $this->getManyBookingsforOneDaySlots($bookingProductSlot, $requestedDate); } /** @@ -101,12 +101,12 @@ class DefaultSlot extends Booking $currentTime = Carbon::now(); $availableFrom = ! $bookingProduct->available_from && $bookingProduct->available_from - ? Carbon::createFromTimeString($bookingProduct->available_from) - : clone $currentTime; + ? 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'); + ? Carbon::createFromTimeString($bookingProduct->available_to) + : Carbon::createFromTimeString('2080-01-01 00:00:00'); $timeDuration = $bookingProductSlot->slots[$requestedDate->format('w')] ?? []; diff --git a/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php b/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php index 41080bdf0..a40a3724b 100644 --- a/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php +++ b/packages/Webkul/BookingProduct/src/Helpers/EventTicket.php @@ -104,11 +104,11 @@ class EventTicket extends Booking 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(); + ->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; } diff --git a/packages/Webkul/BookingProduct/src/Helpers/RentalSlot.php b/packages/Webkul/BookingProduct/src/Helpers/RentalSlot.php index f80770373..a14c5bcd2 100644 --- a/packages/Webkul/BookingProduct/src/Helpers/RentalSlot.php +++ b/packages/Webkul/BookingProduct/src/Helpers/RentalSlot.php @@ -33,16 +33,16 @@ class RentalSlot extends Booking $currentTime = Carbon::now(); $availableFrom = ! $bookingProduct->available_every_week && $bookingProduct->available_from - ? Carbon::createFromTimeString($bookingProduct->available_from) - : Carbon::createFromTimeString($currentTime); + ? 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'); + ? 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')]; + ? $bookingProductSlot->slots + : $bookingProductSlot->slots[$requestedDate->format('w')]; $slots = []; @@ -148,18 +148,18 @@ class RentalSlot extends Booking } $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(); + ->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; } diff --git a/packages/Webkul/BookingProduct/src/Models/Booking.php b/packages/Webkul/BookingProduct/src/Models/Booking.php index 364965886..182974986 100644 --- a/packages/Webkul/BookingProduct/src/Models/Booking.php +++ b/packages/Webkul/BookingProduct/src/Models/Booking.php @@ -11,7 +11,15 @@ class Booking extends Model implements BookingContract { public $timestamps = false; - protected $fillable = ['qty', 'from', 'to', 'order_item_id', 'booking_product_event_ticket_id', 'product_id', 'order_id']; + protected $fillable = [ + 'qty', + 'from', + 'to', + 'order_item_id', + 'booking_product_event_ticket_id', + 'product_id', + 'order_id', + ]; /** * Get the order record associated with the order item. diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProduct.php b/packages/Webkul/BookingProduct/src/Models/BookingProduct.php index c5bb16a8e..287247fcf 100644 --- a/packages/Webkul/BookingProduct/src/Models/BookingProduct.php +++ b/packages/Webkul/BookingProduct/src/Models/BookingProduct.php @@ -8,7 +8,16 @@ use Webkul\BookingProduct\Contracts\BookingProduct as BookingProductContract; class BookingProduct extends Model implements BookingProductContract { - protected $fillable = ['location', 'show_location', 'type', 'qty', 'available_every_week', 'available_from', 'available_to', 'product_id']; + protected $fillable = [ + 'location', + 'show_location', + 'type', + 'qty', + 'available_every_week', + 'available_from', + 'available_to', + 'product_id', + ]; protected $with = ['default_slot', 'appointment_slot', 'event_tickets', 'rental_slot', 'table_slot']; diff --git a/packages/Webkul/BookingProduct/src/Models/BookingProductTableSlot.php b/packages/Webkul/BookingProduct/src/Models/BookingProductTableSlot.php index 668c86e1b..7644d5cfc 100644 --- a/packages/Webkul/BookingProduct/src/Models/BookingProductTableSlot.php +++ b/packages/Webkul/BookingProduct/src/Models/BookingProductTableSlot.php @@ -11,5 +11,15 @@ class BookingProductTableSlot extends Model implements BookingProductTableSlotCo protected $casts = ['slots' => 'array']; - protected $fillable = ['price_type', 'guest_limit', 'guest_capacity', 'duration', 'break_time', 'prevent_scheduling_before', 'same_slot_all_days', 'slots', 'booking_product_id']; + protected $fillable = [ + 'price_type', + 'guest_limit', + 'guest_capacity', + '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/Repositories/BookingProductEventTicketRepository.php b/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php index 7250d5895..0c7f612b7 100644 --- a/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php +++ b/packages/Webkul/BookingProduct/src/Repositories/BookingProductEventTicketRepository.php @@ -36,8 +36,8 @@ class BookingProductEventTicketRepository extends Repository foreach ($data['tickets'] as $ticketId => $ticketInputs) { if (Str::contains($ticketId, 'ticket_')) { $this->create(array_merge([ - 'booking_product_id' => $bookingProduct->id, - ], $ticketInputs)); + 'booking_product_id' => $bookingProduct->id, + ], $ticketInputs)); } else { if (is_numeric($index = $previousTicketIds->search($ticketId))) { $previousTicketIds->forget($index); diff --git a/packages/Webkul/BookingProduct/src/Repositories/BookingRepository.php b/packages/Webkul/BookingProduct/src/Repositories/BookingRepository.php index 173cde59d..e6100e828 100644 --- a/packages/Webkul/BookingProduct/src/Repositories/BookingRepository.php +++ b/packages/Webkul/BookingProduct/src/Repositories/BookingRepository.php @@ -61,14 +61,14 @@ class BookingRepository extends Repository } $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, - ]); + '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); } diff --git a/packages/Webkul/BookingProduct/src/Type/Booking.php b/packages/Webkul/BookingProduct/src/Type/Booking.php index 8ba86f247..044cab4ea 100644 --- a/packages/Webkul/BookingProduct/src/Type/Booking.php +++ b/packages/Webkul/BookingProduct/src/Type/Booking.php @@ -100,8 +100,8 @@ class Booking extends Virtual $this->bookingProductRepository->update(request('booking'), $bookingProduct->id); } else { $this->bookingProductRepository->create(array_merge(request('booking'), [ - 'product_id' => $id - ])); + 'product_id' => $id + ])); } } @@ -158,12 +158,12 @@ class Booking extends Virtual } $cartProducts = parent::prepareForCart([ - 'product_id' => $data['product_id'], - 'quantity' => $qty, - 'booking' => [ - 'ticket_id' => $ticketId, - ], - ]); + 'product_id' => $data['product_id'], + 'quantity' => $qty, + 'booking' => [ + 'ticket_id' => $ticketId, + ], + ]); if (is_string($cartProducts)) { return $cartProducts; diff --git a/packages/Webkul/CMS/src/Models/CmsPage.php b/packages/Webkul/CMS/src/Models/CmsPage.php index bfe00f1d6..55be2c927 100644 --- a/packages/Webkul/CMS/src/Models/CmsPage.php +++ b/packages/Webkul/CMS/src/Models/CmsPage.php @@ -10,7 +10,15 @@ class CmsPage extends TranslatableModel implements CmsPageContract { protected $fillable = ['layout']; - public $translatedAttributes = ['content', 'meta_description', 'meta_title', 'page_title', 'meta_keywords', 'html_content', 'url_key']; + public $translatedAttributes = [ + 'content', + 'meta_description', + 'meta_title', + 'page_title', + 'meta_keywords', + 'html_content', + 'url_key', + ]; protected $with = ['translations']; diff --git a/packages/Webkul/CMS/src/Models/CmsPageTranslation.php b/packages/Webkul/CMS/src/Models/CmsPageTranslation.php index 30bd55e7e..ac47645d5 100644 --- a/packages/Webkul/CMS/src/Models/CmsPageTranslation.php +++ b/packages/Webkul/CMS/src/Models/CmsPageTranslation.php @@ -9,5 +9,14 @@ class CmsPageTranslation extends Model implements CmsPageTranslationContract { public $timestamps = false; - protected $fillable = ['page_title', 'url_key', 'html_content', 'meta_title', 'meta_description', 'meta_keywords', 'locale', 'cms_page_id']; + protected $fillable = [ + 'page_title', + 'url_key', + 'html_content', + 'meta_title', + 'meta_description', + 'meta_keywords', + 'locale', + 'cms_page_id', + ]; } \ No newline at end of file diff --git a/packages/Webkul/CartRule/src/Helpers/CartRule.php b/packages/Webkul/CartRule/src/Helpers/CartRule.php index 4db3cfb0e..fa25075fb 100644 --- a/packages/Webkul/CartRule/src/Helpers/CartRule.php +++ b/packages/Webkul/CartRule/src/Helpers/CartRule.php @@ -152,18 +152,18 @@ class CartRule $cartRules = $this->cartRuleRepository->scopeQuery(function ($query) use ($customerGroupId) { return $query->leftJoin('cart_rule_customer_groups', 'cart_rules.id', '=', 'cart_rule_customer_groups.cart_rule_id') - ->leftJoin('cart_rule_channels', 'cart_rules.id', '=', 'cart_rule_channels.cart_rule_id') - ->where('cart_rule_customer_groups.customer_group_id', $customerGroupId) - ->where('cart_rule_channels.channel_id', core()->getCurrentChannel()->id) - ->where(function ($query1) { - $query1->where('cart_rules.starts_from', '<=', Carbon::now()->format('Y-m-d')) - ->orWhereNull('cart_rules.starts_from'); - }) - ->where(function ($query2) { - $query2->where('cart_rules.ends_till', '>=', Carbon::now()->format('Y-m-d')) - ->orWhereNull('cart_rules.ends_till'); - }) - ->orderBy('sort_order', 'asc'); + ->leftJoin('cart_rule_channels', 'cart_rules.id', '=', 'cart_rule_channels.cart_rule_id') + ->where('cart_rule_customer_groups.customer_group_id', $customerGroupId) + ->where('cart_rule_channels.channel_id', core()->getCurrentChannel()->id) + ->where(function ($query1) { + $query1->where('cart_rules.starts_from', '<=', Carbon::now()->format('Y-m-d')) + ->orWhereNull('cart_rules.starts_from'); + }) + ->where(function ($query2) { + $query2->where('cart_rules.ends_till', '>=', Carbon::now()->format('Y-m-d')) + ->orWhereNull('cart_rules.ends_till'); + }) + ->orderBy('sort_order', 'asc'); })->findWhere(['status' => 1]); return $cartRules; diff --git a/packages/Webkul/CartRule/src/Listeners/Order.php b/packages/Webkul/CartRule/src/Listeners/Order.php index 9d95a1971..eafa26298 100755 --- a/packages/Webkul/CartRule/src/Listeners/Order.php +++ b/packages/Webkul/CartRule/src/Listeners/Order.php @@ -98,18 +98,18 @@ class Order } $ruleCustomer = $this->cartRuleCustomerRepository->findOneWhere([ - 'customer_id' => $order->customer_id, - 'cart_rule_id' => $ruleId - ]); + 'customer_id' => $order->customer_id, + 'cart_rule_id' => $ruleId + ]); if ($ruleCustomer) { $this->cartRuleCustomerRepository->update(['times_used' => $ruleCustomer->times_used + 1], $ruleCustomer->id); } else { $this->cartRuleCustomerRepository->create([ - 'customer_id' => $order->customer_id, - 'cart_rule_id' => $ruleId, - 'times_used' => 1 - ]); + 'customer_id' => $order->customer_id, + 'cart_rule_id' => $ruleId, + 'times_used' => 1 + ]); } } @@ -124,18 +124,18 @@ class Order if ($order->customer_id) { $couponUsage = $this->cartRuleCouponUsageRepository->findOneWhere([ - 'customer_id' => $order->customer_id, - 'cart_rule_coupon_id' => $coupon->id - ]); + 'customer_id' => $order->customer_id, + 'cart_rule_coupon_id' => $coupon->id + ]); if ($couponUsage) { $this->cartRuleCouponUsageRepository->update(['times_used' => $couponUsage->times_used + 1], $couponUsage->id); } else { $this->cartRuleCouponUsageRepository->create([ - 'customer_id' => $order->customer_id, - 'cart_rule_coupon_id' => $coupon->id, - 'times_used' => 1 - ]); + 'customer_id' => $order->customer_id, + 'cart_rule_coupon_id' => $coupon->id, + 'times_used' => 1 + ]); } } } diff --git a/packages/Webkul/CartRule/src/Models/CartRuleCoupon.php b/packages/Webkul/CartRule/src/Models/CartRuleCoupon.php index 045af59a1..d072f1ee4 100644 --- a/packages/Webkul/CartRule/src/Models/CartRuleCoupon.php +++ b/packages/Webkul/CartRule/src/Models/CartRuleCoupon.php @@ -7,7 +7,16 @@ use Webkul\CartRule\Contracts\CartRuleCoupon as CartRuleCouponContract; class CartRuleCoupon extends Model implements CartRuleCouponContract { - protected $fillable = ['code', 'usage_limit', 'usage_per_customer', 'times_used', 'type', 'cart_rule_id', 'expired_at', 'is_primary']; + protected $fillable = [ + 'code', + 'usage_limit', + 'usage_per_customer', + 'times_used', + 'type', + 'cart_rule_id', + 'expired_at', + 'is_primary', + ]; /** * Get the cart rule that owns the cart rule coupon. diff --git a/packages/Webkul/CartRule/src/Repositories/CartRuleCouponRepository.php b/packages/Webkul/CartRule/src/Repositories/CartRuleCouponRepository.php index a5cc737f4..2009919a7 100755 --- a/packages/Webkul/CartRule/src/Repositories/CartRuleCouponRepository.php +++ b/packages/Webkul/CartRule/src/Repositories/CartRuleCouponRepository.php @@ -44,13 +44,13 @@ class CartRuleCouponRepository extends Repository for ($i = 0; $i < $data['coupon_qty']; $i++) { parent::create([ - 'cart_rule_id' => $cartRuleId, - 'code' => $data['code_prefix'] . $this->getRandomString($data['code_format'], $data['code_length']) . $data['code_suffix'], - 'usage_limit' => $cartRule->uses_per_coupon ?? 0, - 'usage_per_customer' => $cartRule->usage_per_customer ?? 0, - 'is_primary' => 0, - 'expired_at' => $cartRule->ends_till ?: null - ]); + 'cart_rule_id' => $cartRuleId, + 'code' => $data['code_prefix'] . $this->getRandomString($data['code_format'], $data['code_length']) . $data['code_suffix'], + 'usage_limit' => $cartRule->uses_per_coupon ?? 0, + 'usage_per_customer' => $cartRule->usage_per_customer ?? 0, + 'is_primary' => 0, + 'expired_at' => $cartRule->ends_till ?: null + ]); } } diff --git a/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php b/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php index bda93ead0..b541518d4 100755 --- a/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php +++ b/packages/Webkul/CartRule/src/Repositories/CartRuleRepository.php @@ -139,13 +139,13 @@ class CartRuleRepository extends Repository if ($data['coupon_type'] && ! $data['use_auto_generation']) { $this->cartRuleCouponRepository->create([ - 'cart_rule_id' => $cartRule->id, - 'code' => $data['coupon_code'], - 'usage_limit' => $data['usage_per_customer'] ?? 0, - 'usage_per_customer' => $data['usage_per_customer'] ?? 0, - 'is_primary' => 1, - 'expired_at' => $data['ends_till'] ?: null - ]); + 'cart_rule_id' => $cartRule->id, + 'code' => $data['coupon_code'], + 'usage_limit' => $data['usage_per_customer'] ?? 0, + 'usage_per_customer' => $data['usage_per_customer'] ?? 0, + 'is_primary' => 1, + 'expired_at' => $data['ends_till'] ?: null + ]); } return $cartRule; @@ -181,29 +181,29 @@ class CartRuleRepository extends Repository if ($cartRuleCoupon) { $this->cartRuleCouponRepository->update([ - 'code' => $data['coupon_code'], - 'usage_limit' => $data['uses_per_coupon'] ?? 0, - 'usage_per_customer' => $data['usage_per_customer'] ?? 0, - 'expired_at' => $data['ends_till'] ?: null - ], $cartRuleCoupon->id); + 'code' => $data['coupon_code'], + 'usage_limit' => $data['uses_per_coupon'] ?? 0, + 'usage_per_customer' => $data['usage_per_customer'] ?? 0, + 'expired_at' => $data['ends_till'] ?: null + ], $cartRuleCoupon->id); } else { $this->cartRuleCouponRepository->create([ - 'cart_rule_id' => $cartRule->id, - 'code' => $data['coupon_code'], - 'usage_limit' => $data['uses_per_coupon'] ?? 0, - 'usage_per_customer' => $data['usage_per_customer'] ?? 0, - 'is_primary' => 1, - 'expired_at' => $data['ends_till'] ?: null - ]); + 'cart_rule_id' => $cartRule->id, + 'code' => $data['coupon_code'], + 'usage_limit' => $data['uses_per_coupon'] ?? 0, + 'usage_per_customer' => $data['usage_per_customer'] ?? 0, + 'is_primary' => 1, + 'expired_at' => $data['ends_till'] ?: null + ]); } } else { $this->cartRuleCouponRepository->deleteWhere(['is_primary' => 1, 'cart_rule_id' => $cartRule->id]); $this->cartRuleCouponRepository->getModel()->where('cart_rule_id', $cartRule->id)->update([ - 'usage_limit' => $data['uses_per_coupon'] ?? 0, - 'usage_per_customer' => $data['usage_per_customer'] ?? 0, - 'expired_at' => $data['ends_till'] ?: null - ]); + 'usage_limit' => $data['uses_per_coupon'] ?? 0, + 'usage_per_customer' => $data['usage_per_customer'] ?? 0, + 'expired_at' => $data['ends_till'] ?: null + ]); } } else { $cartRuleCoupon = $this->cartRuleCouponRepository->deleteWhere(['is_primary' => 1, 'cart_rule_id' => $cartRule->id]); @@ -461,9 +461,9 @@ class CartRuleRepository extends Repository foreach ($this->countryRepository->all() as $country) { $countryStates = $this->countryStateRepository->findWhere( - ['country_id' => $country->id], - ['code', 'default_name as admin_name'] - )->toArray(); + ['country_id' => $country->id], + ['code', 'default_name as admin_name'] + )->toArray(); if (! count($countryStates)) { continue; diff --git a/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleIndex.php b/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleIndex.php index 88cd31d52..5cd65d51c 100644 --- a/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleIndex.php +++ b/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleIndex.php @@ -83,8 +83,8 @@ class CatalogRuleIndex } $productIds = $product->getTypeInstance()->isComposite() - ? $product->getTypeInstance()->getChildrenIds() - : [$product->id]; + ? $product->getTypeInstance()->getChildrenIds() + : [$product->id]; $this->cleanIndexes($productIds); @@ -126,10 +126,12 @@ class CatalogRuleIndex $catalogRules = $this->catalogRuleRepository->scopeQuery(function($query) { return $query->where(function ($query1) { - $query1->where('catalog_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))->orWhereNull('catalog_rules.starts_from'); + $query1->where('catalog_rules.starts_from', '<=', Carbon::now()->format('Y-m-d')) + ->orWhereNull('catalog_rules.starts_from'); }) ->where(function ($query2) { - $query2->where('catalog_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))->orWhereNull('catalog_rules.ends_till'); + $query2->where('catalog_rules.ends_till', '>=', Carbon::now()->format('Y-m-d')) + ->orWhereNull('catalog_rules.ends_till'); }) ->orderBy('sort_order', 'asc'); })->findWhere(['status' => 1]); diff --git a/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleProduct.php b/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleProduct.php index 677c9a2c2..41dd5b1d8 100644 --- a/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleProduct.php +++ b/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleProduct.php @@ -122,10 +122,10 @@ class CatalogRuleProduct { $qb = $this->productRepository->scopeQuery(function($query) use($rule, $product) { $qb = $query->distinct() - ->addSelect('products.*') - ->leftJoin('product_flat', 'products.id', '=', 'product_flat.product_id') - ->leftJoin('channels', 'product_flat.channel', '=', 'channels.code') - ->whereIn('channels.id', $rule->channels()->pluck('id')->toArray()); + ->addSelect('products.*') + ->leftJoin('product_flat', 'products.id', '=', 'product_flat.product_id') + ->leftJoin('channels', 'product_flat.channel', '=', 'channels.code') + ->whereIn('channels.id', $rule->channels()->pluck('id')->toArray()); if ($product) { $qb->where('products.id', $product->id); @@ -192,10 +192,10 @@ class CatalogRuleProduct $query = $query->leftJoin('product_attribute_values as ' . 'pav_' . $attribute->code, function($qb) use($attribute) { $qb = $qb->where('pav_' . $attribute->code . '.channel', $attribute->value_per_channel ? core()->getDefaultChannelCode() : null) - ->where('pav_' . $attribute->code . '.locale', $attribute->value_per_locale ? app()->getLocale() : null); + ->where('pav_' . $attribute->code . '.locale', $attribute->value_per_locale ? app()->getLocale() : null); $qb->on('products.id', 'pav_' . $attribute->code . '.product_id') - ->where('pav_' . $attribute->code . '.attribute_id', $attribute->id); + ->where('pav_' . $attribute->code . '.attribute_id', $attribute->id); }); $query = $query->addSelect('pav_' . $attribute->code . '.' . ProductAttributeValue::$attributeTypeFields[$attribute->type] . ' as ' . $attribute->code); @@ -213,13 +213,13 @@ class CatalogRuleProduct { $results = $this->catalogRuleProductRepository->scopeQuery(function($query) use($product) { $qb = $query->distinct() - ->select('catalog_rule_products.*') - ->leftJoin('products', 'catalog_rule_products.product_id', '=', 'products.id') - ->orderBy('channel_id', 'asc') - ->orderBy('customer_group_id', 'asc') - ->orderBy('product_id', 'asc') - ->orderBy('sort_order', 'asc') - ->orderBy('catalog_rule_id', 'asc'); + ->select('catalog_rule_products.*') + ->leftJoin('products', 'catalog_rule_products.product_id', '=', 'products.id') + ->orderBy('channel_id', 'asc') + ->orderBy('customer_group_id', 'asc') + ->orderBy('product_id', 'asc') + ->orderBy('sort_order', 'asc') + ->orderBy('catalog_rule_id', 'asc'); $qb = $this->addAttributeToSelect('price', $qb); diff --git a/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleProductPrice.php b/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleProductPrice.php index 727a0d251..47e1d031d 100644 --- a/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleProductPrice.php +++ b/packages/Webkul/CatalogRule/src/Helpers/CatalogRuleProductPrice.php @@ -211,10 +211,10 @@ class CatalogRuleProductPrice } return $this->catalogRuleProductPriceRepository->findOneWhere([ - 'product_id' => $product->id, - 'channel_id' => core()->getCurrentChannel()->id, - 'customer_group_id' => $customerGroupId, - 'rule_date' => Carbon::now()->format('Y-m-d'), - ]); + 'product_id' => $product->id, + 'channel_id' => core()->getCurrentChannel()->id, + 'customer_group_id' => $customerGroupId, + 'rule_date' => Carbon::now()->format('Y-m-d'), + ]); } } \ No newline at end of file diff --git a/packages/Webkul/CatalogRule/src/Models/CatalogRule.php b/packages/Webkul/CatalogRule/src/Models/CatalogRule.php index 00e991506..152e3b52f 100644 --- a/packages/Webkul/CatalogRule/src/Models/CatalogRule.php +++ b/packages/Webkul/CatalogRule/src/Models/CatalogRule.php @@ -9,7 +9,19 @@ use Webkul\Customer\Models\CustomerGroupProxy; class CatalogRule extends Model implements CatalogRuleContract { - protected $fillable = ['name', 'description', 'starts_from', 'ends_till', 'status', 'condition_type', 'conditions', 'end_other_rules', 'action_type', 'discount_amount', 'sort_order']; + protected $fillable = [ + 'name', + 'description', + 'starts_from', + 'ends_till', + 'status', + 'condition_type', + 'conditions', + 'end_other_rules', + 'action_type', + 'discount_amount', + 'sort_order', + ]; protected $casts = [ 'conditions' => 'array' diff --git a/packages/Webkul/CatalogRule/src/Models/CatalogRuleProduct.php b/packages/Webkul/CatalogRule/src/Models/CatalogRuleProduct.php index dfa513113..6e71642f5 100644 --- a/packages/Webkul/CatalogRule/src/Models/CatalogRuleProduct.php +++ b/packages/Webkul/CatalogRule/src/Models/CatalogRuleProduct.php @@ -9,5 +9,16 @@ class CatalogRuleProduct extends Model implements CatalogRuleProductContract { public $timestamps = false; - protected $fillable = ['starts_from', 'ends_till', 'discount_amount', 'action_type', 'end_other_rules', 'sort_order', 'catalog_rule_id', 'channel_id', 'customer_group_id', 'product_id']; + protected $fillable = [ + 'starts_from', + 'ends_till', + 'discount_amount', + 'action_type', + 'end_other_rules', + 'sort_order', + 'catalog_rule_id', + 'channel_id', + 'customer_group_id', + 'product_id', + ]; } \ No newline at end of file diff --git a/packages/Webkul/CatalogRule/src/Models/CatalogRuleProductPrice.php b/packages/Webkul/CatalogRule/src/Models/CatalogRuleProductPrice.php index 59c1731bd..0a9e5c6c5 100644 --- a/packages/Webkul/CatalogRule/src/Models/CatalogRuleProductPrice.php +++ b/packages/Webkul/CatalogRule/src/Models/CatalogRuleProductPrice.php @@ -9,5 +9,13 @@ class CatalogRuleProductPrice extends Model implements CatalogRuleProductPriceCo { public $timestamps = false; - protected $fillable = ['price', 'rule_date', 'starts_from', 'ends_till', 'catalog_rule_id', 'channel_id', 'customer_group_id']; + protected $fillable = [ + 'price', + 'rule_date', + 'starts_from', + 'ends_till', + 'catalog_rule_id', + 'channel_id', + 'customer_group_id', + ]; } \ No newline at end of file diff --git a/packages/Webkul/Category/src/Database/Seeders/CategoryTableSeeder.php b/packages/Webkul/Category/src/Database/Seeders/CategoryTableSeeder.php index b70fbaae0..ad5a6e1e6 100755 --- a/packages/Webkul/Category/src/Database/Seeders/CategoryTableSeeder.php +++ b/packages/Webkul/Category/src/Database/Seeders/CategoryTableSeeder.php @@ -15,11 +15,31 @@ class CategoryTableSeeder extends Seeder $now = Carbon::now(); DB::table('categories')->insert([ - ['id' => '1','position' => '1','image' => NULL,'status' => '1','_lft' => '1','_rgt' => '14','parent_id' => NULL, 'created_at' => $now, 'updated_at' => $now] + [ + 'id' => '1', + 'position' => '1', + 'image' => NULL, + 'status' => '1', + '_lft' => '1', + '_rgt' => '14', + 'parent_id' => NULL, + 'created_at' => $now, + 'updated_at' => $now, + ] ]); DB::table('category_translations')->insert([ - ['id' => '1','name' => 'Root','slug' => 'root','description' => 'Root','meta_title' => '','meta_description' => '','meta_keywords' => '','category_id' => '1','locale' => 'en'] + [ + 'id' => '1', + 'name' => 'Root', + 'slug' => 'root', + 'description' => 'Root', + 'meta_title' => '', + 'meta_description' => '', + 'meta_keywords' => '', + 'category_id' => '1', + 'locale' => 'en', + ] ]); } } \ No newline at end of file diff --git a/packages/Webkul/Category/src/Models/Category.php b/packages/Webkul/Category/src/Models/Category.php index c6e8decfb..549a7a4e7 100755 --- a/packages/Webkul/Category/src/Models/Category.php +++ b/packages/Webkul/Category/src/Models/Category.php @@ -21,7 +21,15 @@ class Category extends TranslatableModel implements CategoryContract { use NodeTrait; - public $translatedAttributes = ['name', 'description', 'slug', 'url_path', 'meta_title', 'meta_description', 'meta_keywords']; + public $translatedAttributes = [ + 'name', + 'description', + 'slug', + 'url_path', + 'meta_title', + 'meta_description', + 'meta_keywords', + ]; protected $fillable = ['position', 'status', 'display_mode', 'parent_id']; diff --git a/packages/Webkul/Category/src/Repositories/CategoryRepository.php b/packages/Webkul/Category/src/Repositories/CategoryRepository.php index 6617f5458..7096938bd 100755 --- a/packages/Webkul/Category/src/Repositories/CategoryRepository.php +++ b/packages/Webkul/Category/src/Repositories/CategoryRepository.php @@ -72,8 +72,8 @@ class CategoryRepository extends Repository public function getCategoryTree($id = null) { return $id - ? $this->model::orderBy('position', 'ASC')->where('id', '!=', $id)->get()->toTree() - : $this->model::orderBy('position', 'ASC')->get()->toTree(); + ? $this->model::orderBy('position', 'ASC')->where('id', '!=', $id)->get()->toTree() + : $this->model::orderBy('position', 'ASC')->get()->toTree(); } /** @@ -85,8 +85,8 @@ class CategoryRepository extends Repository public function getCategoryTreeWithoutDescendant($id = null) { return $id - ? $this->model::orderBy('position', 'ASC')->where('id', '!=', $id)->whereNotDescendantOf($id)->get()->toTree() - : $this->model::orderBy('position', 'ASC')->get()->toTree(); + ? $this->model::orderBy('position', 'ASC')->where('id', '!=', $id)->whereNotDescendantOf($id)->get()->toTree() + : $this->model::orderBy('position', 'ASC')->get()->toTree(); } /** @@ -114,8 +114,8 @@ class CategoryRepository extends Repository } return $categories[$id] = $id - ? $this->model::orderBy('position', 'ASC')->where('status', 1)->descendantsOf($id)->toTree() - : $this->model::orderBy('position', 'ASC')->where('status', 1)->get()->toTree(); + ? $this->model::orderBy('position', 'ASC')->where('status', 1)->descendantsOf($id)->toTree() + : $this->model::orderBy('position', 'ASC')->where('status', 1)->get()->toTree(); } /** diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index ac76ab0a7..220310a4f 100755 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -171,8 +171,8 @@ class Cart } else { if (isset($cartProduct['parent_id']) && $cartItem->parent_id != $parentCartItem->id) { $cartItem = $this->cartItemRepository->create(array_merge($cartProduct, [ - 'cart_id' => $cart->id - ])); + 'cart_id' => $cart->id + ])); } else { if ($cartItem->product->getTypeInstance()->showQuantityBox() === false) { return ['warning' => __('shop::app.checkout.cart.integrity.qty_impossible')]; @@ -268,12 +268,12 @@ class Cart Event::dispatch('checkout.cart.update.before', $item); $this->cartItemRepository->update([ - 'quantity' => $quantity, - 'total' => core()->convertPrice($item->price * $quantity), - 'base_total' => $item->price * $quantity, - 'total_weight' => $item->weight * $quantity, - 'base_total_weight' => $item->weight * $quantity, - ], $itemId); + 'quantity' => $quantity, + 'total' => core()->convertPrice($item->price * $quantity), + 'base_total' => $item->price * $quantity, + 'total_weight' => $item->weight * $quantity, + 'base_total_weight' => $item->weight * $quantity, + ], $itemId); Event::dispatch('checkout.cart.update.after', $item); } @@ -556,11 +556,13 @@ class Cart } } else { if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) { - $this->cartAddressRepository->create(array_merge($billingAddress, - ['address_type' => 'shipping'])); + $this->cartAddressRepository->create( + array_merge($billingAddress, ['address_type' => 'shipping']) + ); } else { - $this->cartAddressRepository->create(array_merge($shippingAddress, - ['address_type' => 'shipping'])); + $this->cartAddressRepository->create( + array_merge($shippingAddress, ['address_type' => 'shipping']) + ); } } } @@ -569,9 +571,13 @@ class Cart if ($cart->haveStockableItems()) { if (isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) { - $this->cartAddressRepository->create(array_merge($billingAddress, ['address_type' => 'shipping'])); + $this->cartAddressRepository->create( + array_merge($billingAddress, ['address_type' => 'shipping']) + ); } else { - $this->cartAddressRepository->create(array_merge($shippingAddress, ['address_type' => 'shipping'])); + $this->cartAddressRepository->create( + array_merge($shippingAddress, ['address_type' => 'shipping']) + ); } } } @@ -1037,9 +1043,9 @@ class Cart } $wishlistItems = $this->wishlistRepository->findWhere([ - 'customer_id' => $this->getCurrentCustomer()->user()->id, - 'product_id' => $cartItem->product_id, - ]); + 'customer_id' => $this->getCurrentCustomer()->user()->id, + 'product_id' => $cartItem->product_id, + ]); $found = false; @@ -1057,11 +1063,11 @@ class Cart if (!$found) { $this->wishlistRepository->create([ - 'channel_id' => $cart->channel_id, - 'customer_id' => $this->getCurrentCustomer()->user()->id, - 'product_id' => $cartItem->product_id, - 'additional' => $cartItem->additional, - ]); + 'channel_id' => $cart->channel_id, + 'customer_id' => $this->getCurrentCustomer()->user()->id, + 'product_id' => $cartItem->product_id, + 'additional' => $cartItem->additional, + ]); } $result = $this->cartItemRepository->delete($itemId); diff --git a/packages/Webkul/Checkout/src/Database/Factories/CartAddressFactory.php b/packages/Webkul/Checkout/src/Database/Factories/CartAddressFactory.php index 536369a49..53e389de0 100644 --- a/packages/Webkul/Checkout/src/Database/Factories/CartAddressFactory.php +++ b/packages/Webkul/Checkout/src/Database/Factories/CartAddressFactory.php @@ -7,6 +7,7 @@ use Webkul\Checkout\Models\CartAddress; $factory->define(CartAddress::class, function (Faker $faker) { $now = date("Y-m-d H:i:s"); + return [ 'first_name' => $faker->firstName(), 'last_name' => $faker->lastName, diff --git a/packages/Webkul/Checkout/src/Models/CartShippingRate.php b/packages/Webkul/Checkout/src/Models/CartShippingRate.php index 7c4447e33..e3c8d41a3 100755 --- a/packages/Webkul/Checkout/src/Models/CartShippingRate.php +++ b/packages/Webkul/Checkout/src/Models/CartShippingRate.php @@ -7,7 +7,17 @@ use Webkul\Checkout\Contracts\CartShippingRate as CartShippingRateContract; class CartShippingRate extends Model implements CartShippingRateContract { - protected $fillable = ['carrier', 'carrier_title', 'method', 'method_title', 'method_description', 'price', 'base_price', 'discount_amount', 'base_discount_amount']; + protected $fillable = [ + 'carrier', + 'carrier_title', + 'method', + 'method_title', + 'method_description', + 'price', + 'base_price', + 'discount_amount', + 'base_discount_amount', + ]; /** * Get the post that owns the comment. diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 0212f201d..5a5cbe96b 100755 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -392,8 +392,8 @@ class Core } $targetCurrency = ! $targetCurrencyCode - ? $this->getCurrentCurrency() - : $this->currencyRepository->findOneByField('code', $targetCurrencyCode); + ? $this->getCurrentCurrency() + : $this->currencyRepository->findOneByField('code', $targetCurrencyCode); if (! $targetCurrency) { return $amount; @@ -427,8 +427,8 @@ class Core public function convertToBasePrice($amount, $targetCurrencyCode = null) { $targetCurrency = ! $targetCurrencyCode - ? $this->getCurrentCurrency() - : $this->currencyRepository->findOneByField('code', $targetCurrencyCode); + ? $this->getCurrentCurrency() + : $this->currencyRepository->findOneByField('code', $targetCurrencyCode); if (! $targetCurrency) { return $amount; @@ -821,8 +821,8 @@ class Core $start = Carbon::createFromTimeString($date->format('Y-m-d') . ' 00:00:01'); $end = $totalMonths - 1 == $i - ? $endDate - : Carbon::createFromTimeString($date->format('Y-m-d') . ' 23:59:59'); + ? $endDate + : Carbon::createFromTimeString($date->format('Y-m-d') . ' 23:59:59'); $timeIntervals[] = ['start' => $start, 'end' => $end, 'formatedDate' => $date->format('M')]; } @@ -832,11 +832,11 @@ class Core $date->addWeeks($i); $start = $i == 0 - ? $startDate - : Carbon::createFromTimeString($this->xWeekRange($date, 0) . ' 00:00:01'); + ? $startDate + : Carbon::createFromTimeString($this->xWeekRange($date, 0) . ' 00:00:01'); $end = $totalWeeks - 1 == $i - ? $endDate - : Carbon::createFromTimeString($this->xWeekRange($date, 1) . ' 23:59:59'); + ? $endDate + : Carbon::createFromTimeString($this->xWeekRange($date, 1) . ' 23:59:59'); $timeIntervals[] = ['start' => $start, 'end' => $end, 'formatedDate' => $date->format('d M')]; } @@ -966,6 +966,7 @@ class Core } $finalKey = array_shift($keys); + if (isset($array[$finalKey])) { $array[$finalKey] = $this->arrayMerge($array[$finalKey], $value); } else { @@ -978,6 +979,7 @@ class Core protected function arrayMerge(array &$array1, array &$array2) { $merged = $array1; + foreach ($array2 as $key => &$value) { if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { $merged[$key] = $this->arrayMerge($merged[$key], $value); diff --git a/packages/Webkul/Core/src/Database/Seeders/ChannelTableSeeder.php b/packages/Webkul/Core/src/Database/Seeders/ChannelTableSeeder.php index e2fbfe068..bf8428331 100755 --- a/packages/Webkul/Core/src/Database/Seeders/ChannelTableSeeder.php +++ b/packages/Webkul/Core/src/Database/Seeders/ChannelTableSeeder.php @@ -12,31 +12,31 @@ class ChannelTableSeeder extends Seeder DB::table('channels')->delete(); DB::table('channels')->insert([ - 'id' => 1, - 'code' => 'default', - 'name' => 'Default', - 'root_category_id' => 1, - 'home_page_content' => '

@include("shop::home.slider") @include("shop::home.featured-products") @include("shop::home.new-products")

', - 'footer_content' => '
Quick Links
Connect With Us
', - 'name' => 'Default', - 'default_locale_id' => 1, - 'base_currency_id' => 1, - 'home_seo' => '{"meta_title": "Demo store", "meta_keywords": "Demo store meta keyword", "meta_description": "Demo store meta description"}' - ]); + 'id' => 1, + 'code' => 'default', + 'name' => 'Default', + 'root_category_id' => 1, + 'home_page_content' => '

@include("shop::home.slider") @include("shop::home.featured-products") @include("shop::home.new-products")

', + 'footer_content' => '
Quick Links
Connect With Us
', + 'name' => 'Default', + 'default_locale_id' => 1, + 'base_currency_id' => 1, + 'home_seo' => '{"meta_title": "Demo store", "meta_keywords": "Demo store meta keyword", "meta_description": "Demo store meta description"}' + ]); DB::table('channel_currencies')->insert([ - 'channel_id' => 1, - 'currency_id' => 1 - ]); + 'channel_id' => 1, + 'currency_id' => 1 + ]); DB::table('channel_locales')->insert([ - 'channel_id' => 1, - 'locale_id' => 1 - ]); + 'channel_id' => 1, + 'locale_id' => 1 + ]); DB::table('channel_inventory_sources')->insert([ - 'channel_id' => 1, - 'inventory_source_id' => 1 - ]); + 'channel_id' => 1, + 'inventory_source_id' => 1 + ]); } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Database/Seeders/CurrencyTableSeeder.php b/packages/Webkul/Core/src/Database/Seeders/CurrencyTableSeeder.php index d12ea21ee..2a201ea98 100755 --- a/packages/Webkul/Core/src/Database/Seeders/CurrencyTableSeeder.php +++ b/packages/Webkul/Core/src/Database/Seeders/CurrencyTableSeeder.php @@ -14,14 +14,15 @@ class CurrencyTableSeeder extends Seeder DB::table('currencies')->delete(); DB::table('currencies')->insert([ - 'id' => 1, - 'code' => 'USD', - 'name' => 'US Dollar' - ], [ - 'id' => 2, - 'code' => 'EUR', - 'name' => 'Euro', - 'symbol' => '€' - ]); + 'id' => 1, + 'code' => 'USD', + 'name' => 'US Dollar' + ], [ + 'id' => 2, + 'code' => 'EUR', + 'name' => 'Euro', + 'symbol' => '€' + ] + ); } } diff --git a/packages/Webkul/Core/src/Database/Seeders/LocalesTableSeeder.php b/packages/Webkul/Core/src/Database/Seeders/LocalesTableSeeder.php index 31f5045eb..9088231c6 100755 --- a/packages/Webkul/Core/src/Database/Seeders/LocalesTableSeeder.php +++ b/packages/Webkul/Core/src/Database/Seeders/LocalesTableSeeder.php @@ -21,6 +21,7 @@ class LocalesTableSeeder extends Seeder 'id' => 2, 'code' => 'fr', 'name' => 'French', - ]); + ] + ); } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Eloquent/TranslatableModel.php b/packages/Webkul/Core/src/Eloquent/TranslatableModel.php index d83f24f32..985c1dd97 100755 --- a/packages/Webkul/Core/src/Eloquent/TranslatableModel.php +++ b/packages/Webkul/Core/src/Eloquent/TranslatableModel.php @@ -24,6 +24,7 @@ class TranslatableModel extends Model protected function isKeyALocale($key) { $chunks = explode('-', $key); + if (count($chunks) > 1) { if (Locale::where('code', '=', end($chunks))->first()) { return true; @@ -47,8 +48,7 @@ class TranslatableModel extends Model return $this->defaultLocale; } - return config('translatable.locale') - ?: app()->make('translator')->getLocale(); + return config('translatable.locale') ?: app()->make('translator')->getLocale(); } } diff --git a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php index 8cf00f91e..22fc99438 100644 --- a/packages/Webkul/Core/src/Helpers/Laravel5Helper.php +++ b/packages/Webkul/Core/src/Helpers/Laravel5Helper.php @@ -58,6 +58,7 @@ class Laravel5Helper extends Laravel5 'brand' => 'text_value', 'guest_checkout' => 'boolean_value', ]; + if (! array_key_exists($attribute, $attributes)) { return null; } @@ -222,6 +223,7 @@ class Laravel5Helper extends Laravel5 private function createAttributeValues(int $productId, array $attributeValues = []): void { $I = $this; + $productAttributeValues = [ 'sku', 'url_key', @@ -248,7 +250,7 @@ class Laravel5Helper extends Laravel5 if (array_key_exists($attribute, $attributeValues)) { $fieldName = self::getAttributeFieldName($attribute); - if (!array_key_exists($fieldName, $data)) { + if (! array_key_exists($fieldName, $data)) { $data[$fieldName] = $attributeValues[$attribute]; } else { $data = [$fieldName => $attributeValues[$attribute]]; diff --git a/packages/Webkul/Core/src/Http/Controllers/ExchangeRateController.php b/packages/Webkul/Core/src/Http/Controllers/ExchangeRateController.php index 660080706..562a40103 100755 --- a/packages/Webkul/Core/src/Http/Controllers/ExchangeRateController.php +++ b/packages/Webkul/Core/src/Http/Controllers/ExchangeRateController.php @@ -87,7 +87,7 @@ class ExchangeRateController extends Controller { $this->validate(request(), [ 'target_currency' => ['required', 'unique:currency_exchange_rates,target_currency'], - 'rate' => 'required|numeric' + 'rate' => 'required|numeric', ]); Event::dispatch('core.exchange_rate.create.before'); @@ -126,7 +126,7 @@ class ExchangeRateController extends Controller { $this->validate(request(), [ 'target_currency' => ['required', 'unique:currency_exchange_rates,target_currency,' . $id], - 'rate' => 'required|numeric' + 'rate' => 'required|numeric', ]); Event::dispatch('core.exchange_rate.update.before', $id); @@ -155,8 +155,8 @@ class ExchangeRateController extends Controller 'success' => false, 'rates' => null, 'error' => trans('admin::app.exchange-rate.exchange-class-not-found', [ - 'service' => $service - ]) + 'service' => $service, + ]), ], 400); } @@ -165,13 +165,13 @@ class ExchangeRateController extends Controller return response()->json([ 'success' => true, - 'rates' => 'rates' + 'rates' => 'rates', ], 200); } else { return response()->json([ 'success' => false, 'rates' => null, - 'error' => trans('admin::app.exchange-rate.invalid-config') + 'error' => trans('admin::app.exchange-rate.invalid-config'), ], 400); } } diff --git a/packages/Webkul/Core/src/Http/Controllers/LocaleController.php b/packages/Webkul/Core/src/Http/Controllers/LocaleController.php index 2ad6aa20c..f3754bac8 100755 --- a/packages/Webkul/Core/src/Http/Controllers/LocaleController.php +++ b/packages/Webkul/Core/src/Http/Controllers/LocaleController.php @@ -70,7 +70,7 @@ class LocaleController extends Controller $this->validate(request(), [ 'code' => ['required', 'unique:locales,code', new \Webkul\Core\Contracts\Validations\Code], 'name' => 'required', - 'direction' => 'in:ltr,rtl' + 'direction' => 'in:ltr,rtl', ]); Event::dispatch('core.locale.create.before'); @@ -108,7 +108,7 @@ class LocaleController extends Controller $this->validate(request(), [ 'code' => ['required', 'unique:locales,code,' . $id, new \Webkul\Core\Contracts\Validations\Code], 'name' => 'required', - 'direction' => 'in:ltr,rtl' + 'direction' => 'in:ltr,rtl', ]); Event::dispatch('core.locale.update.before', $id); diff --git a/packages/Webkul/Core/src/Http/Controllers/SliderController.php b/packages/Webkul/Core/src/Http/Controllers/SliderController.php index 75d8a26e9..578962224 100755 --- a/packages/Webkul/Core/src/Http/Controllers/SliderController.php +++ b/packages/Webkul/Core/src/Http/Controllers/SliderController.php @@ -76,7 +76,7 @@ class SliderController extends Controller $this->validate(request(), [ 'title' => 'string|required', 'channel_id' => 'required', - 'image.*' => 'required|mimes:jpeg,bmp,png,jpg' + 'image.*' => 'required|mimes:jpeg,bmp,png,jpg', ]); $result = $this->sliderRepository->save(request()->all()); @@ -111,11 +111,12 @@ class SliderController extends Controller $this->validate(request(), [ 'title' => 'string|required', 'channel_id' => 'required', - 'image.*' => 'sometimes|mimes:jpeg,bmp,png,jpg' + 'image.*' => 'sometimes|mimes:jpeg,bmp,png,jpg', ]); if ( is_null(request()->image)) { session()->flash('error', trans('admin::app.settings.sliders.update-fail')); + return redirect()->back(); } diff --git a/packages/Webkul/Core/src/Http/Controllers/SubscriptionController.php b/packages/Webkul/Core/src/Http/Controllers/SubscriptionController.php index 27b660e2e..c1fb07f5b 100755 --- a/packages/Webkul/Core/src/Http/Controllers/SubscriptionController.php +++ b/packages/Webkul/Core/src/Http/Controllers/SubscriptionController.php @@ -78,10 +78,11 @@ class SubscriptionController extends Controller $result = $subscriber->update($data); - if ($result) + if ($result) { session()->flash('success', trans('admin::app.customers.subscribers.update-success')); - else + } else { session()->flash('error', trans('admin::app.customers.subscribers.update-failed')); + } return redirect()->route($this->_config['redirect']); } @@ -104,6 +105,7 @@ class SubscriptionController extends Controller return response()->json(['message' => true], 200); } catch (\Exception $e) { report($e); + session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Subscriber'])); } diff --git a/packages/Webkul/Core/src/Models/Channel.php b/packages/Webkul/Core/src/Models/Channel.php index 6bd746d19..2d7445b5f 100755 --- a/packages/Webkul/Core/src/Models/Channel.php +++ b/packages/Webkul/Core/src/Models/Channel.php @@ -10,7 +10,19 @@ use Webkul\Core\Contracts\Channel as ChannelContract; class Channel extends Model implements ChannelContract { - protected $fillable = ['code', 'name', 'description', 'theme', 'home_page_content', 'footer_content', 'hostname', 'default_locale_id', 'base_currency_id', 'root_category_id', 'home_seo']; + protected $fillable = [ + 'code', + 'name', + 'description', + 'theme', + 'home_page_content', + 'footer_content', + 'hostname', + 'default_locale_id', + 'base_currency_id', + 'root_category_id', + 'home_seo', + ]; /** * Get the channel locales. diff --git a/packages/Webkul/Core/src/Models/CoreConfig.php b/packages/Webkul/Core/src/Models/CoreConfig.php index 55c36f9bd..262eb2d0b 100755 --- a/packages/Webkul/Core/src/Models/CoreConfig.php +++ b/packages/Webkul/Core/src/Models/CoreConfig.php @@ -16,7 +16,10 @@ class CoreConfig extends Model implements CoreConfigContract protected $table = 'core_config'; protected $fillable = [ - 'code', 'value','channel_code','locale_code' + 'code', + 'value', + 'channel_code', + 'locale_code', ]; protected $hidden = ['token']; diff --git a/packages/Webkul/Core/src/Models/CurrencyExchangeRate.php b/packages/Webkul/Core/src/Models/CurrencyExchangeRate.php index 075585ee1..2168d8780 100755 --- a/packages/Webkul/Core/src/Models/CurrencyExchangeRate.php +++ b/packages/Webkul/Core/src/Models/CurrencyExchangeRate.php @@ -13,6 +13,7 @@ class CurrencyExchangeRate extends Model implements CurrencyExchangeRateContract * @var array */ protected $fillable = [ - 'target_currency', 'rate' + 'target_currency', + 'rate', ]; } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Models/Locale.php b/packages/Webkul/Core/src/Models/Locale.php index 572e576a5..79e6a879d 100755 --- a/packages/Webkul/Core/src/Models/Locale.php +++ b/packages/Webkul/Core/src/Models/Locale.php @@ -13,6 +13,8 @@ class Locale extends Model implements LocaleContract * @var array */ protected $fillable = [ - 'code', 'name', 'direction' + 'code', + 'name', + 'direction', ]; } diff --git a/packages/Webkul/Core/src/Models/Slider.php b/packages/Webkul/Core/src/Models/Slider.php index 4dc9812f4..24815b6a3 100755 --- a/packages/Webkul/Core/src/Models/Slider.php +++ b/packages/Webkul/Core/src/Models/Slider.php @@ -16,7 +16,10 @@ class Slider extends Model implements SliderContract protected $table = 'sliders'; protected $fillable = [ - 'title', 'path', 'content', 'channel_id' + 'title', + 'path', + 'content', + 'channel_id', ]; /** diff --git a/packages/Webkul/Core/src/Models/SubscribersList.php b/packages/Webkul/Core/src/Models/SubscribersList.php index 53d0e0b76..d0145facd 100755 --- a/packages/Webkul/Core/src/Models/SubscribersList.php +++ b/packages/Webkul/Core/src/Models/SubscribersList.php @@ -16,7 +16,10 @@ class SubscribersList extends Model implements SubscribersListContract protected $table = 'subscribers_list'; protected $fillable = [ - 'email', 'is_subscribed', 'token', 'channel_id' + 'email', + 'is_subscribed', + 'token', + 'channel_id', ]; protected $hidden = ['token']; diff --git a/packages/Webkul/Core/src/Repositories/CoreConfigRepository.php b/packages/Webkul/Core/src/Repositories/CoreConfigRepository.php index 567f39e3c..8d27999f5 100755 --- a/packages/Webkul/Core/src/Repositories/CoreConfigRepository.php +++ b/packages/Webkul/Core/src/Repositories/CoreConfigRepository.php @@ -85,11 +85,11 @@ class CoreConfigRepository extends Repository if (! count($coreConfigValue)) { $this->model->create([ - 'code' => $fieldName, - 'value' => $value, - 'locale_code' => $localeBased ? $locale : null, - 'channel_code' => $channelBased ? $channel : null - ]); + 'code' => $fieldName, + 'value' => $value, + 'locale_code' => $localeBased ? $locale : null, + 'channel_code' => $channelBased ? $channel : null + ]); } else { foreach ($coreConfigValue as $coreConfig) { Storage::delete($coreConfig['value']); @@ -98,11 +98,11 @@ class CoreConfigRepository extends Repository $this->model->destroy($coreConfig['id']); } else { $coreConfig->update([ - 'code' => $fieldName, - 'value' => $value, - 'locale_code' => $localeBased ? $locale : null, - 'channel_code' => $channelBased ? $channel : null - ]); + 'code' => $fieldName, + 'value' => $value, + 'locale_code' => $localeBased ? $locale : null, + 'channel_code' => $channelBased ? $channel : null + ]); } } } @@ -117,6 +117,7 @@ class CoreConfigRepository extends Repository */ public function recuressiveArray(array $formData, $method) { static $data = []; + static $recuressiveArrayData = []; foreach ($formData as $form => $formValue) { diff --git a/packages/Webkul/Core/src/Repositories/CurrencyRepository.php b/packages/Webkul/Core/src/Repositories/CurrencyRepository.php index a4df09924..72b589ddb 100755 --- a/packages/Webkul/Core/src/Repositories/CurrencyRepository.php +++ b/packages/Webkul/Core/src/Repositories/CurrencyRepository.php @@ -31,7 +31,6 @@ class CurrencyRepository extends Repository } else { return false; } - } } } \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php index 3336a2791..1ebe18272 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php @@ -190,6 +190,7 @@ class RegistrationController extends Controller return redirect()->back(); } + session()->flash('success', trans('shop::app.customer.signup-form.verification-sent')); return redirect()->back(); diff --git a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php index 592e49dc4..cd6b3dc4a 100755 --- a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php @@ -88,10 +88,10 @@ class WishlistController extends Controller ]; $checked = $this->wishlistRepository->findWhere([ - 'channel_id' => core()->getCurrentChannel()->id, - 'product_id' => $itemId, - 'customer_id' => auth()->guard('customer')->user()->id - ]); + 'channel_id' => core()->getCurrentChannel()->id, + 'product_id' => $itemId, + 'customer_id' => auth()->guard('customer')->user()->id + ]); //accidental case if some one adds id of the product in the anchor tag amd gives id of a variant. if ($product->parent_id != null) { diff --git a/packages/Webkul/Customer/src/Http/Middleware/RedirectIfNotCustomer.php b/packages/Webkul/Customer/src/Http/Middleware/RedirectIfNotCustomer.php index 38adeb4e3..310ef5da6 100755 --- a/packages/Webkul/Customer/src/Http/Middleware/RedirectIfNotCustomer.php +++ b/packages/Webkul/Customer/src/Http/Middleware/RedirectIfNotCustomer.php @@ -24,6 +24,7 @@ class RedirectIfNotCustomer Auth::guard($guard)->logout(); session()->flash('warning', trans('shop::app.customer.login-form.not-activated')); + return redirect()->route('customer.session.index'); } } diff --git a/packages/Webkul/Customer/src/Mail/RegistrationEmail.php b/packages/Webkul/Customer/src/Mail/RegistrationEmail.php index 624d9fabe..9a89d4c61 100644 --- a/packages/Webkul/Customer/src/Mail/RegistrationEmail.php +++ b/packages/Webkul/Customer/src/Mail/RegistrationEmail.php @@ -31,7 +31,7 @@ class RegistrationEmail extends Mailable public function build() { return $this->to($this->data['email']) - ->subject(trans('shop::app.mail.customer.registration.customer-registration')) - ->view('shop::emails.customer.registration')->with('data', $this->data); + ->subject(trans('shop::app.mail.customer.registration.customer-registration')) + ->view('shop::emails.customer.registration')->with('data', $this->data); } } \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Mail/VerificationEmail.php b/packages/Webkul/Customer/src/Mail/VerificationEmail.php index 99f7a5eea..23ebb05a4 100755 --- a/packages/Webkul/Customer/src/Mail/VerificationEmail.php +++ b/packages/Webkul/Customer/src/Mail/VerificationEmail.php @@ -31,7 +31,12 @@ class VerificationEmail extends Mailable public function build() { return $this->to($this->verificationData['email']) - ->subject(trans('shop::app.mail.customer.verification.subject')) - ->view('shop::emails.customer.verification-email')->with('data', ['email' => $this->verificationData['email'], 'token' => $this->verificationData['token']]); + ->subject(trans('shop::app.mail.customer.verification.subject')) + ->view('shop::emails.customer.verification-email') + ->with('data', [ + 'email' => $this->verificationData['email'], + 'token' => $this->verificationData['token'], + ] + ); } } \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Models/Customer.php b/packages/Webkul/Customer/src/Models/Customer.php index c9f4d194c..be81d5e72 100755 --- a/packages/Webkul/Customer/src/Models/Customer.php +++ b/packages/Webkul/Customer/src/Models/Customer.php @@ -17,21 +17,38 @@ class Customer extends Authenticatable implements CustomerContract, JWTSubject protected $table = 'customers'; - protected $fillable = ['first_name', 'last_name', 'gender', 'date_of_birth', 'email', 'phone', 'password', 'api_token', 'customer_group_id', 'subscribed_to_news_letter', 'is_verified', 'token', 'notes', 'status']; + protected $fillable = [ + 'first_name', + 'last_name', + 'gender', + 'date_of_birth', + 'email', + 'phone', + 'password', + 'api_token', + 'customer_group_id', + 'subscribed_to_news_letter', + 'is_verified', + 'token', + 'notes', + 'status', + ]; protected $hidden = ['password', 'api_token', 'remember_token']; /** * Get the customer full name. */ - public function getNameAttribute() { + public function getNameAttribute() + { return ucfirst($this->first_name) . ' ' . ucfirst($this->last_name); } /** * Email exists or not */ - public function emailExists($email) { + public function emailExists($email) + { $results = $this->where('email', $email); if ($results->count() == 0) { @@ -79,42 +96,48 @@ class Customer extends Authenticatable implements CustomerContract, JWTSubject /** * Customer's relation with wishlist items */ - public function wishlist_items() { + public function wishlist_items() + { return $this->hasMany(WishlistProxy::modelClass(), 'customer_id'); } /** * get all cart inactive cart instance of a customer */ - public function all_carts() { + public function all_carts() + { return $this->hasMany(CartProxy::modelClass(), 'customer_id'); } /** * get inactive cart inactive cart instance of a customer */ - public function inactive_carts() { + public function inactive_carts() + { return $this->hasMany(CartProxy::modelClass(), 'customer_id')->where('is_active', 0); } /** * get active cart inactive cart instance of a customer */ - public function active_carts() { + public function active_carts() + { return $this->hasMany(CartProxy::modelClass(), 'customer_id')->where('is_active', 1); } /** * get all reviews of a customer */ - public function all_reviews() { + public function all_reviews() + { return $this->hasMany(ProductReviewProxy::modelClass(), 'customer_id'); } /** * get all orders of a customer */ - public function all_orders() { + public function all_orders() + { return $this->hasMany(OrderProxy::modelClass(), 'customer_id'); } diff --git a/packages/Webkul/Customer/src/Models/Wishlist.php b/packages/Webkul/Customer/src/Models/Wishlist.php index dd762464e..09efa4e80 100755 --- a/packages/Webkul/Customer/src/Models/Wishlist.php +++ b/packages/Webkul/Customer/src/Models/Wishlist.php @@ -14,7 +14,15 @@ class Wishlist extends Model implements WishlistContract 'additional' => 'array', ]; - protected $fillable = ['channel_id', 'product_id', 'customer_id', 'additional', 'moved_to_cart', 'shared', 'time_of_moving']; + protected $fillable = [ + 'channel_id', + 'product_id', + 'customer_id', + 'additional', + 'moved_to_cart', + 'shared', + 'time_of_moving' + ]; /** * The Product that belong to the wishlist. diff --git a/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php b/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php index d3a85feca..cda9741c6 100755 --- a/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php +++ b/packages/Webkul/Customer/src/Notifications/CustomerResetPassword.php @@ -23,8 +23,9 @@ class CustomerResetPassword extends ResetPassword return (new MailMessage) ->subject(__('shop::app.mail.forget-password.subject') ) ->view('shop::emails.customer.forget-password', [ - 'user_name' => $notifiable->name, - 'token' => $this->token - ]); + 'user_name' => $notifiable->name, + 'token' => $this->token + ] + ); } } diff --git a/packages/Webkul/Inventory/src/Http/Controllers/InventorySourceController.php b/packages/Webkul/Inventory/src/Http/Controllers/InventorySourceController.php index 7279cfbe1..29c91b3e9 100755 --- a/packages/Webkul/Inventory/src/Http/Controllers/InventorySourceController.php +++ b/packages/Webkul/Inventory/src/Http/Controllers/InventorySourceController.php @@ -169,6 +169,7 @@ class InventorySourceController extends Controller return response()->json(['message' => true], 200); } catch (\Exception $e) { report($e); + session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Inventory source'])); } } diff --git a/packages/Webkul/Payment/src/Payment.php b/packages/Webkul/Payment/src/Payment.php index ac769f5fb..257e41509 100755 --- a/packages/Webkul/Payment/src/Payment.php +++ b/packages/Webkul/Payment/src/Payment.php @@ -17,10 +17,10 @@ class Payment $paymentMethods = $this->getPaymentMethods(); return [ - 'jump_to_section' => 'payment', - 'paymentMethods' => $this->getPaymentMethods(), - 'html' => view('shop::checkout.onepage.payment', compact('paymentMethods'))->render() - ]; + 'jump_to_section' => 'payment', + 'paymentMethods' => $this->getPaymentMethods(), + 'html' => view('shop::checkout.onepage.payment', compact('paymentMethods'))->render() + ]; } /** diff --git a/packages/Webkul/Paypal/src/Payment/Paypal.php b/packages/Webkul/Paypal/src/Payment/Paypal.php index 8a9b55822..f13ec5704 100755 --- a/packages/Webkul/Paypal/src/Payment/Paypal.php +++ b/packages/Webkul/Paypal/src/Payment/Paypal.php @@ -22,9 +22,9 @@ abstract class Paypal extends Payment public function getPaypalUrl($params = []) { return sprintf('https://www.%spaypal.com/cgi-bin/webscr%s', - $this->getConfigData('sandbox') ? 'sandbox.' : '', - $params ? '?' . http_build_query($params) : '' - ); + $this->getConfigData('sandbox') ? 'sandbox.' : '', + $params ? '?' . http_build_query($params) : '' + ); } /** diff --git a/packages/Webkul/Product/src/Console/Commands/PriceUpdate.php b/packages/Webkul/Product/src/Console/Commands/PriceUpdate.php index c15f09c33..a7fa5d5cf 100644 --- a/packages/Webkul/Product/src/Console/Commands/PriceUpdate.php +++ b/packages/Webkul/Product/src/Console/Commands/PriceUpdate.php @@ -70,13 +70,13 @@ class PriceUpdate extends Command $product->parent->save(); } else { $bundleProducts = $this->productFlatRepository->getModel() - ->addSelect('product_flat.*') - ->distinct() - ->leftJoin('products', 'product_flat.product_id', 'products.id') - ->leftJoin('product_bundle_options', 'products.id', 'product_bundle_options.product_id') - ->leftJoin('product_bundle_option_products', 'product_bundle_options.id', 'product_bundle_option_products.product_bundle_option_id') - ->where('product_bundle_option_products.product_id', $product->product_id) - ->get(); + ->addSelect('product_flat.*') + ->distinct() + ->leftJoin('products', 'product_flat.product_id', 'products.id') + ->leftJoin('product_bundle_options', 'products.id', 'product_bundle_options.product_id') + ->leftJoin('product_bundle_option_products', 'product_bundle_options.id', 'product_bundle_option_productsproduct_bundle_option_id') + ->where('product_bundle_option_products.product_id', $product->product_id) + ->get(); foreach ($bundleProducts as $bundleProduct) { $bundleProduct->min_price = $bundleProduct->getTypeInstance()->getMinimalPrice(); diff --git a/packages/Webkul/Product/src/Helpers/Review.php b/packages/Webkul/Product/src/Helpers/Review.php index 1ecb2e209..a63db1dff 100755 --- a/packages/Webkul/Product/src/Helpers/Review.php +++ b/packages/Webkul/Product/src/Helpers/Review.php @@ -88,10 +88,10 @@ class Review extends AbstractProduct public function getPercentageRating($product) { $reviews = $product->reviews()->where('status', 'approved') - ->select('rating', DB::raw('count(*) as total')) - ->groupBy('rating') - ->orderBy('rating','desc') - ->get(); + ->select('rating', DB::raw('count(*) as total')) + ->groupBy('rating') + ->orderBy('rating','desc') + ->get(); $totalReviews = $this->getTotalReviews($product); diff --git a/packages/Webkul/Product/src/Helpers/Toolbar.php b/packages/Webkul/Product/src/Helpers/Toolbar.php index 71a5aa726..23a305a18 100755 --- a/packages/Webkul/Product/src/Helpers/Toolbar.php +++ b/packages/Webkul/Product/src/Helpers/Toolbar.php @@ -49,9 +49,9 @@ class Toolbar extends AbstractProduct $keys = explode('-', $key); return request()->fullUrlWithQuery([ - 'sort' => current($keys), - 'order' => end($keys) - ]); + 'sort' => current($keys), + 'order' => end($keys) + ]); } /** @@ -63,8 +63,8 @@ class Toolbar extends AbstractProduct public function getLimitUrl($limit) { return request()->fullUrlWithQuery([ - 'limit' => $limit - ]); + 'limit' => $limit + ]); } /** @@ -76,8 +76,8 @@ class Toolbar extends AbstractProduct public function getModeUrl($mode) { return request()->fullUrlWithQuery([ - 'mode' => $mode - ]); + 'mode' => $mode + ]); } /** diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index de2c4cf0a..1335ee42d 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -246,6 +246,7 @@ class ProductController extends Controller return response()->json(['message' => true], 200); } catch (\Exception $e) { report($e); + session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Product'])); } @@ -328,10 +329,10 @@ class ProductController extends Controller foreach ($this->productRepository->searchProductByAttribute(request()->input('query')) as $row) { $results[] = [ - 'id' => $row->product_id, - 'sku' => $row->sku, - 'name' => $row->name, - ]; + 'id' => $row->product_id, + 'sku' => $row->sku, + 'name' => $row->name, + ]; } return response()->json($results); diff --git a/packages/Webkul/Product/src/Http/Controllers/ReviewController.php b/packages/Webkul/Product/src/Http/Controllers/ReviewController.php index a189ee7a8..9d6c89720 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ReviewController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ReviewController.php @@ -140,10 +140,11 @@ class ReviewController extends Controller } } - if (! $suppressFlash) + if (! $suppressFlash) { session()->flash('success', trans('admin::app.datagrid.mass-ops.delete-success', ['resource' => 'Reviews'])); - else + } else { session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'Reviews'])); + } return redirect()->route($this->_config['redirect']); @@ -194,10 +195,11 @@ class ReviewController extends Controller } } - if (! $suppressFlash) + if (! $suppressFlash) { session()->flash('success', trans('admin::app.datagrid.mass-ops.update-success', ['resource' => 'Reviews'])); - else + } else { session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'Reviews'])); + } return redirect()->route($this->_config['redirect']); } else { diff --git a/packages/Webkul/Product/src/Http/Requests/ProductForm.php b/packages/Webkul/Product/src/Http/Requests/ProductForm.php index a4b0f9e2a..b42adf964 100755 --- a/packages/Webkul/Product/src/Http/Requests/ProductForm.php +++ b/packages/Webkul/Product/src/Http/Requests/ProductForm.php @@ -93,10 +93,10 @@ class ProductForm extends FormRequest if ($attribute->type == 'text' && $attribute->validation) { array_push($validations, - $attribute->validation == 'decimal' - ? new \Webkul\Core\Contracts\Validations\Decimal - : $attribute->validation - ); + $attribute->validation == 'decimal' + ? new \Webkul\Core\Contracts\Validations\Decimal + : $attribute->validation + ); } if ($attribute->type == 'price') { diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php index df235823e..43e13c51d 100644 --- a/packages/Webkul/Product/src/Listeners/ProductFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php @@ -223,9 +223,16 @@ class ProductFlat if ($attribute->value_per_channel) { if ($attribute->value_per_locale) { - $productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('locale', $locale->code)->where('attribute_id', $attribute->id)->first(); + $productAttributeValue = $product->attribute_values() + ->where('channel', $channel->code) + ->where('locale', $locale->code) + ->where('attribute_id', $attribute->id) + ->first(); } else { - $productAttributeValue = $product->attribute_values()->where('channel', $channel->code)->where('attribute_id', $attribute->id)->first(); + $productAttributeValue = $product->attribute_values() + ->where('channel', $channel->code) + ->where('attribute_id', $attribute->id) + ->first(); } } else { if ($attribute->value_per_locale) { diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index 8db9c3cd7..3ea88f43c 100755 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -181,8 +181,8 @@ class Product extends Model implements ProductContract public function inventory_source_qty($inventorySourceId) { return $this->inventories() - ->where('inventory_source_id', $inventorySourceId) - ->sum('qty'); + ->where('inventory_source_id', $inventorySourceId) + ->sum('qty'); } /** @@ -264,7 +264,7 @@ class Product extends Model implements ProductContract $this->attributes[$key] = ''; $attribute = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class) - ->getAttributeByCode($key); + ->getAttributeByCode($key); $this->attributes[$key] = $this->getCustomAttributeValue($attribute); @@ -286,7 +286,7 @@ class Product extends Model implements ProductContract if (isset($this->id)) { $familyAttributes = core()->getSingletonInstance(\Webkul\Attribute\Repositories\AttributeRepository::class) - ->getFamilyAttributes($this->attribute_family); + ->getFamilyAttributes($this->attribute_family); foreach ($familyAttributes as $attribute) { if (in_array($attribute->code, $hiddenAttributes)) { diff --git a/packages/Webkul/Product/src/Models/ProductBundleOptionProduct.php b/packages/Webkul/Product/src/Models/ProductBundleOptionProduct.php index 2faa5efce..f7f375217 100644 --- a/packages/Webkul/Product/src/Models/ProductBundleOptionProduct.php +++ b/packages/Webkul/Product/src/Models/ProductBundleOptionProduct.php @@ -9,7 +9,14 @@ class ProductBundleOptionProduct extends Model implements ProductBundleOptionPro { public $timestamps = false; - protected $fillable = ['qty', 'is_user_defined', 'sort_order', 'is_default', 'product_bundle_option_id', 'product_id']; + protected $fillable = [ + 'qty', + 'is_user_defined', + 'sort_order', + 'is_default', + 'product_bundle_option_id', + 'product_id', + ]; /** * Get the bundle option that owns this resource. diff --git a/packages/Webkul/Product/src/Models/ProductDownloadableLink.php b/packages/Webkul/Product/src/Models/ProductDownloadableLink.php index 712c2c89e..2105ab0fe 100644 --- a/packages/Webkul/Product/src/Models/ProductDownloadableLink.php +++ b/packages/Webkul/Product/src/Models/ProductDownloadableLink.php @@ -10,7 +10,21 @@ class ProductDownloadableLink extends TranslatableModel implements ProductDownlo { public $translatedAttributes = ['title']; - protected $fillable = ['title', 'price', 'url', 'file', 'file_name', 'type', 'sample_url', 'sample_file', 'sample_file_name', 'sample_type', 'sort_order', 'product_id', 'downloads']; + protected $fillable = [ + 'title', + 'price', + 'url', + 'file', + 'file_name', + 'type', + 'sample_url', + 'sample_file', + 'sample_file_name', + 'sample_type', + 'sort_order', + 'product_id', + 'downloads', + ]; protected $with = ['translations']; diff --git a/packages/Webkul/Product/src/Models/ProductReview.php b/packages/Webkul/Product/src/Models/ProductReview.php index 2544b941d..88f654d8b 100755 --- a/packages/Webkul/Product/src/Models/ProductReview.php +++ b/packages/Webkul/Product/src/Models/ProductReview.php @@ -9,7 +9,15 @@ use Webkul\Product\Contracts\ProductReview as ProductReviewContract; class ProductReview extends Model implements ProductReviewContract { - protected $fillable = ['comment', 'title', 'rating', 'status', 'product_id', 'customer_id', 'name']; + protected $fillable = [ + 'comment', + 'title', + 'rating', + 'status', + 'product_id', + 'customer_id', + 'name', + ]; /** * Get the product attribute family that owns the product. diff --git a/packages/Webkul/Product/src/Repositories/ProductBundleOptionProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductBundleOptionProductRepository.php index 51b0ecf3e..cbea8833a 100644 --- a/packages/Webkul/Product/src/Repositories/ProductBundleOptionProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductBundleOptionProductRepository.php @@ -33,8 +33,8 @@ class ProductBundleOptionProductRepository extends Repository foreach ($data['products'] as $bundleOptionProductId => $bundleOptionProductInputs) { if (Str::contains($bundleOptionProductId, 'product_')) { $this->create(array_merge([ - 'product_bundle_option_id' => $productBundleOption->id, - ], $bundleOptionProductInputs)); + 'product_bundle_option_id' => $productBundleOption->id, + ], $bundleOptionProductInputs)); } else { if (is_numeric($index = $previousBundleOptionProductIds->search($bundleOptionProductId))) { $previousBundleOptionProductIds->forget($index); diff --git a/packages/Webkul/Product/src/Repositories/ProductBundleOptionRepository.php b/packages/Webkul/Product/src/Repositories/ProductBundleOptionRepository.php index e9dcdaa36..2b9d557d4 100644 --- a/packages/Webkul/Product/src/Repositories/ProductBundleOptionRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductBundleOptionRepository.php @@ -55,8 +55,8 @@ class ProductBundleOptionRepository extends Repository foreach ($data['bundle_options'] as $bundleOptionId => $bundleOptionInputs) { if (Str::contains($bundleOptionId, 'option_')) { $productBundleOption = $this->create(array_merge([ - 'product_id' => $product->id, - ], $bundleOptionInputs)); + 'product_id' => $product->id, + ], $bundleOptionInputs)); } else { $productBundleOption = $this->find($bundleOptionId); diff --git a/packages/Webkul/Product/src/Repositories/ProductDownloadableLinkRepository.php b/packages/Webkul/Product/src/Repositories/ProductDownloadableLinkRepository.php index e1f9b02d4..b0eaf1442 100755 --- a/packages/Webkul/Product/src/Repositories/ProductDownloadableLinkRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductDownloadableLinkRepository.php @@ -57,8 +57,8 @@ class ProductDownloadableLinkRepository extends Repository foreach ($data['downloadable_links'] as $linkId => $data) { if (Str::contains($linkId, 'link_')) { $this->create(array_merge([ - 'product_id' => $product->id, - ], $data)); + 'product_id' => $product->id, + ], $data)); } else { if (is_numeric($index = $previousLinkIds->search($linkId))) { $previousLinkIds->forget($index); diff --git a/packages/Webkul/Product/src/Repositories/ProductDownloadableSampleRepository.php b/packages/Webkul/Product/src/Repositories/ProductDownloadableSampleRepository.php index 41bcfd53d..c298d0f0a 100755 --- a/packages/Webkul/Product/src/Repositories/ProductDownloadableSampleRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductDownloadableSampleRepository.php @@ -55,8 +55,8 @@ class ProductDownloadableSampleRepository extends Repository foreach ($data['downloadable_samples'] as $sampleId => $data) { if (Str::contains($sampleId, 'sample_')) { $this->create(array_merge([ - 'product_id' => $product->id, - ], $data)); + 'product_id' => $product->id, + ], $data)); } else { if (is_numeric($index = $previousSampleIds->search($sampleId))) { $previousSampleIds->forget($index); diff --git a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php index 1bf4bcbaa..3a066f55a 100644 --- a/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductFlatRepository.php @@ -30,9 +30,9 @@ class ProductFlatRepository extends Repository } return $this->model - ->leftJoin('product_categories', 'product_flat.product_id', 'product_categories.product_id') - ->where('product_categories.category_id', $category->id) - ->max('max_price'); + ->leftJoin('product_categories', 'product_flat.product_id', 'product_categories.product_id') + ->where('product_categories.category_id', $category->id) + ->max('max_price'); } /** @@ -44,20 +44,18 @@ class ProductFlatRepository extends Repository public function getCategoryProductAttribute($categoryId) { $qb = $this->model - ->leftJoin('product_categories', 'product_flat.product_id', 'product_categories.product_id') - ->where('product_categories.category_id', $categoryId) - ->where('product_flat.channel', core()->getCurrentChannelCode()) - ->where('product_flat.locale', app()->getLocale()); + ->leftJoin('product_categories', 'product_flat.product_id', 'product_categories.product_id') + ->where('product_categories.category_id', $categoryId) + ->where('product_flat.channel', core()->getCurrentChannelCode()) + ->where('product_flat.locale', app()->getLocale()); - $productArrributes = $qb - ->leftJoin('product_attribute_values as pa', 'product_flat.product_id', 'pa.product_id') - ->pluck('pa.attribute_id') - ->toArray(); + $productArrributes = $qb->leftJoin('product_attribute_values as pa', 'product_flat.product_id', 'pa.product_id') + ->pluck('pa.attribute_id') + ->toArray(); - $productSuperArrributes = $qb - ->leftJoin('product_super_attributes as ps', 'product_flat.product_id', 'ps.product_id') - ->pluck('ps.attribute_id') - ->toArray(); + $productSuperArrributes = $qb->leftJoin('product_super_attributes as ps', 'product_flat.product_id', 'ps.product_id') + ->pluck('ps.attribute_id') + ->toArray(); $productCategoryArrributes = array_unique(array_merge($productArrributes, $productSuperArrributes)); diff --git a/packages/Webkul/Product/src/Repositories/ProductGroupedProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductGroupedProductRepository.php index dcd32e309..48b3199d7 100644 --- a/packages/Webkul/Product/src/Repositories/ProductGroupedProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductGroupedProductRepository.php @@ -32,8 +32,8 @@ class ProductGroupedProductRepository extends Repository foreach ($data['links'] as $linkId => $linkInputs) { if (Str::contains($linkId, 'link_')) { $this->create(array_merge([ - 'product_id' => $product->id, - ], $linkInputs)); + 'product_id' => $product->id, + ], $linkInputs)); } else { if (is_numeric($index = $previousGroupedProductIds->search($linkId))) { $previousGroupedProductIds->forget($index); diff --git a/packages/Webkul/Product/src/Repositories/ProductImageRepository.php b/packages/Webkul/Product/src/Repositories/ProductImageRepository.php index 6d69e5ba8..0bee073ff 100755 --- a/packages/Webkul/Product/src/Repositories/ProductImageRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductImageRepository.php @@ -41,9 +41,9 @@ class ProductImageRepository extends Repository if (Str::contains($imageId, 'image_')) { if (request()->hasFile($file)) { $this->create([ - 'path' => request()->file($file)->store($dir), - 'product_id' => $product->id - ]); + 'path' => request()->file($file)->store($dir), + 'product_id' => $product->id + ]); } } else { if (is_numeric($index = $previousImageIds->search($imageId))) { diff --git a/packages/Webkul/Product/src/Repositories/ProductInventoryRepository.php b/packages/Webkul/Product/src/Repositories/ProductInventoryRepository.php index 997dc2d18..fb0501d6d 100755 --- a/packages/Webkul/Product/src/Repositories/ProductInventoryRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductInventoryRepository.php @@ -35,10 +35,10 @@ class ProductInventoryRepository extends Repository $qty = is_null($qty) ? 0 : $qty; $productInventory = $this->findOneWhere([ - 'product_id' => $product->id, - 'inventory_source_id' => $inventorySourceId, - 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 - ]); + 'product_id' => $product->id, + 'inventory_source_id' => $inventorySourceId, + 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 + ]); if ($productInventory) { $productInventory->qty = $qty; @@ -46,11 +46,11 @@ class ProductInventoryRepository extends Repository $productInventory->save(); } else { $this->create([ - 'qty' => $qty, - 'product_id' => $product->id, - 'inventory_source_id' => $inventorySourceId, - 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 - ]); + 'qty' => $qty, + 'product_id' => $product->id, + 'inventory_source_id' => $inventorySourceId, + 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 + ]); } } } diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index aab13503f..2c8fd2aa9 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -119,12 +119,12 @@ class ProductRepository extends Repository $locale = request()->get('locale') ?: app()->getLocale(); $qb = $query->distinct() - ->addSelect('product_flat.*') - ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') - ->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id') - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->whereNotNull('product_flat.url_key'); + ->addSelect('product_flat.*') + ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') + ->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id') + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->whereNotNull('product_flat.url_key'); if ($categoryId) { $qb->where('product_categories.category_id', $categoryId); @@ -140,8 +140,8 @@ class ProductRepository extends Repository $queryBuilder = $qb->leftJoin('product_flat as flat_variants', function($qb) use($channel, $locale) { $qb->on('product_flat.id', '=', 'flat_variants.parent_id') - ->where('flat_variants.channel', $channel) - ->where('flat_variants.locale', $locale); + ->where('flat_variants.channel', $channel) + ->where('flat_variants.locale', $locale); }); if (isset($params['search'])) @@ -165,9 +165,9 @@ class ProductRepository extends Repository $qb = $qb->where(function($query1) use($qb) { $aliases = [ - 'products' => 'filter_', - 'variants' => 'variant_filter_' - ]; + 'products' => 'filter_', + 'variants' => 'variant_filter_' + ]; foreach($aliases as $table => $alias) { $query1 = $query1->orWhere(function($query2) use ($qb, $table, $alias) { @@ -196,7 +196,7 @@ class ProductRepository extends Repository }); } else { $query2->where('product_flat.min_price', '>=', core()->convertToBasePrice(current($temp))) - ->where('product_flat.min_price', '<=', core()->convertToBasePrice(end($temp))); + ->where('product_flat.min_price', '<=', core()->convertToBasePrice(end($temp))); } } }); @@ -218,10 +218,10 @@ class ProductRepository extends Repository public function findBySlugOrFail($slug, $columns = null) { $product = app(ProductFlatRepository::class)->findOneWhere([ - 'url_key' => $slug, - 'locale' => app()->getLocale(), - 'channel' => core()->getCurrentChannelCode(), - ]); + 'url_key' => $slug, + 'locale' => app()->getLocale(), + 'channel' => core()->getCurrentChannelCode(), + ]); if (! $product) { throw (new ModelNotFoundException)->setModel( @@ -261,13 +261,13 @@ class ProductRepository extends Repository $locale = request()->get('locale') ?: app()->getLocale(); return $query->distinct() - ->addSelect('product_flat.*') - ->where('product_flat.status', 1) - ->where('product_flat.visible_individually', 1) - ->where('product_flat.new', 1) - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->orderBy('product_id', 'desc'); + ->addSelect('product_flat.*') + ->where('product_flat.status', 1) + ->where('product_flat.visible_individually', 1) + ->where('product_flat.new', 1) + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->orderBy('product_id', 'desc'); })->paginate(4); return $results; @@ -286,13 +286,13 @@ class ProductRepository extends Repository $locale = request()->get('locale') ?: app()->getLocale(); return $query->distinct() - ->addSelect('product_flat.*') - ->where('product_flat.status', 1) - ->where('product_flat.visible_individually', 1) - ->where('product_flat.featured', 1) - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->orderBy('product_id', 'desc'); + ->addSelect('product_flat.*') + ->where('product_flat.status', 1) + ->where('product_flat.visible_individually', 1) + ->where('product_flat.featured', 1) + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->orderBy('product_id', 'desc'); })->paginate(4); return $results; @@ -311,14 +311,14 @@ class ProductRepository extends Repository $locale = request()->get('locale') ?: app()->getLocale(); return $query->distinct() - ->addSelect('product_flat.*') - ->where('product_flat.status', 1) - ->where('product_flat.visible_individually', 1) - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->whereNotNull('product_flat.url_key') - ->where('product_flat.name', 'like', '%' . urldecode($term) . '%') - ->orderBy('product_id', 'desc'); + ->addSelect('product_flat.*') + ->where('product_flat.status', 1) + ->where('product_flat.visible_individually', 1) + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->whereNotNull('product_flat.url_key') + ->where('product_flat.name', 'like', '%' . urldecode($term) . '%') + ->orderBy('product_id', 'desc'); })->paginate(16); return $results; @@ -364,14 +364,14 @@ class ProductRepository extends Repository $locale = request()->get('locale') ?: app()->getLocale(); return $query->distinct() - ->addSelect('product_flat.*') - ->addSelect('product_flat.product_id as id') - ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') - ->where('products.type', 'simple') - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->where('product_flat.name', 'like', '%' . urldecode($term) . '%') - ->orderBy('product_id', 'desc'); + ->addSelect('product_flat.*') + ->addSelect('product_flat.product_id as id') + ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') + ->where('products.type', 'simple') + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->where('product_flat.name', 'like', '%' . urldecode($term) . '%') + ->orderBy('product_id', 'desc'); })->get(); } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 98f8ff55a..12e65c1aa 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -203,11 +203,11 @@ abstract class AbstractType } $attributeValue = $this->attributeValueRepository->findOneWhere([ - 'product_id' => $product->id, - 'attribute_id' => $attribute->id, - 'channel' => $attribute->value_per_channel ? $data['channel'] : null, - 'locale' => $attribute->value_per_locale ? $data['locale'] : null - ]); + 'product_id' => $product->id, + 'attribute_id' => $attribute->id, + 'channel' => $attribute->value_per_channel ? $data['channel'] : null, + 'locale' => $attribute->value_per_locale ? $data['locale'] : null + ]); if (! $attributeValue) { $this->attributeValueRepository->create([ @@ -373,9 +373,9 @@ abstract class AbstractType $total = 0; $channelInventorySourceIds = core()->getCurrentChannel() - ->inventory_sources() - ->where('status', 1) - ->pluck('id'); + ->inventory_sources() + ->where('status', 1) + ->pluck('id'); foreach ($this->product->inventories as $inventory) { if (is_numeric($index = $channelInventorySourceIds->search($inventory->inventory_source_id))) { @@ -384,8 +384,8 @@ abstract class AbstractType } $orderedInventory = $this->product->ordered_inventories() - ->where('channel_id', core()->getCurrentChannel()->id) - ->first(); + ->where('channel_id', core()->getCurrentChannel()->id) + ->first(); if ($orderedInventory) { $total -= $orderedInventory->qty; diff --git a/packages/Webkul/Product/src/Type/Bundle.php b/packages/Webkul/Product/src/Type/Bundle.php index 55e9b5120..905d368b7 100644 --- a/packages/Webkul/Product/src/Type/Bundle.php +++ b/packages/Webkul/Product/src/Type/Bundle.php @@ -235,9 +235,10 @@ class Bundle extends AbstractType foreach ($option->bundle_option_products as $index => $bundleOptionProduct) { $optionPrices[] = $bundleOptionProduct->qty - * ($minPrice + * ($minPrice ? $bundleOptionProduct->product->getTypeInstance()->getMinimalPrice() - : $bundleOptionProduct->product->price); + : $bundleOptionProduct->product->price + ); } return $optionPrices; @@ -467,21 +468,21 @@ class Bundle extends AbstractType } $optionProduct = $this->productBundleOptionProductRepository->findOneWhere([ - 'id' => $optionProductId, - 'product_bundle_option_id' => $optionId - ]); + 'id' => $optionProductId, + 'product_bundle_option_id' => $optionId + ]); $qty = $data['bundle_option_qty'][$optionId] ?? $optionProduct->qty; if (! isset($products[$optionProduct->product_id])) { $products[$optionProduct->product_id] = [ - 'product_id' => $optionProduct->product_id, - 'quantity' => $qty, - ]; + 'product_id' => $optionProduct->product_id, + 'quantity' => $qty, + ]; } else { $products[$optionProduct->product_id] = array_merge($products[$optionProduct->product_id], [ - 'quantity' => $products[$optionProduct->product_id]['quantity'] + $qty - ]); + 'quantity' => $products[$optionProduct->product_id]['quantity'] + $qty + ]); } } } diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index 5d667f58e..3b9e51c5b 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -136,27 +136,28 @@ class Configurable extends AbstractType { if (! count($data)) { $data = [ - 'sku' => $product->sku . '-variant-' . implode('-', $permutation), - 'name' => '', - 'inventories' => [], - 'price' => 0, - 'weight' => 0, - 'status' => 1 - ]; + 'sku' => $product->sku . '-variant-' . implode('-', $permutation), + 'name' => '', + 'inventories' => [], + 'price' => 0, + 'weight' => 0, + 'status' => 1 + ]; } $typeOfVariants = 'simple'; $productInstance = app(config('product_types.' . $product->type . '.class')); + if (isset($productInstance->variantsType) && ! in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) { $typeOfVariants = $productInstance->variantsType; } $variant = $this->productRepository->getModel()->create([ - 'parent_id' => $product->id, - 'type' => $typeOfVariants, - 'attribute_family_id' => $product->attribute_family_id, - 'sku' => $data['sku'], - ]); + 'parent_id' => $product->id, + 'type' => $typeOfVariants, + 'attribute_family_id' => $product->attribute_family_id, + 'sku' => $data['sku'], + ]); foreach (['sku', 'name', 'price', 'weight', 'status'] as $attributeCode) { $attribute = $this->attributeRepository->findOneByField('code', $attributeCode); @@ -166,50 +167,50 @@ class Configurable extends AbstractType foreach (core()->getAllChannels() as $channel) { foreach (core()->getAllLocales() as $locale) { $this->attributeValueRepository->create([ - 'product_id' => $variant->id, - 'attribute_id' => $attribute->id, - 'channel' => $channel->code, - 'locale' => $locale->code, - 'value' => $data[$attributeCode] - ]); + 'product_id' => $variant->id, + 'attribute_id' => $attribute->id, + 'channel' => $channel->code, + 'locale' => $locale->code, + 'value' => $data[$attributeCode] + ]); } } } else { foreach (core()->getAllChannels() as $channel) { $this->attributeValueRepository->create([ - 'product_id' => $variant->id, - 'attribute_id' => $attribute->id, - 'channel' => $channel->code, - 'value' => $data[$attributeCode] - ]); + 'product_id' => $variant->id, + 'attribute_id' => $attribute->id, + 'channel' => $channel->code, + 'value' => $data[$attributeCode] + ]); } } } else { if ($attribute->value_per_locale) { foreach (core()->getAllLocales() as $locale) { $this->attributeValueRepository->create([ - 'product_id' => $variant->id, - 'attribute_id' => $attribute->id, - 'locale' => $locale->code, - 'value' => $data[$attributeCode] - ]); + 'product_id' => $variant->id, + 'attribute_id' => $attribute->id, + 'locale' => $locale->code, + 'value' => $data[$attributeCode] + ]); } } else { $this->attributeValueRepository->create([ - 'product_id' => $variant->id, - 'attribute_id' => $attribute->id, - 'value' => $data[$attributeCode] - ]); + 'product_id' => $variant->id, + 'attribute_id' => $attribute->id, + 'value' => $data[$attributeCode] + ]); } } } foreach ($permutation as $attributeId => $optionId) { $this->attributeValueRepository->create([ - 'product_id' => $variant->id, - 'attribute_id' => $attributeId, - 'value' => $optionId - ]); + 'product_id' => $variant->id, + 'attribute_id' => $attributeId, + 'value' => $optionId + ]); } $this->productInventoryRepository->saveInventories($data, $variant); @@ -232,20 +233,20 @@ class Configurable extends AbstractType $attribute = $this->attributeRepository->findOneByField('code', $attributeCode); $attributeValue = $this->attributeValueRepository->findOneWhere([ - 'product_id' => $id, - 'attribute_id' => $attribute->id, - 'channel' => $attribute->value_per_channel ? $data['channel'] : null, - 'locale' => $attribute->value_per_locale ? $data['locale'] : null - ]); + 'product_id' => $id, + 'attribute_id' => $attribute->id, + 'channel' => $attribute->value_per_channel ? $data['channel'] : null, + 'locale' => $attribute->value_per_locale ? $data['locale'] : null + ]); if (! $attributeValue) { $this->attributeValueRepository->create([ - 'product_id' => $id, - 'attribute_id' => $attribute->id, - 'value' => $data[$attribute->code], - 'channel' => $attribute->value_per_channel ? $data['channel'] : null, - 'locale' => $attribute->value_per_locale ? $data['locale'] : null - ]); + 'product_id' => $id, + 'attribute_id' => $attribute->id, + 'value' => $data[$attribute->code], + 'channel' => $attribute->value_per_channel ? $data['channel'] : null, + 'locale' => $attribute->value_per_locale ? $data['locale'] : null + ]); } else { $this->attributeValueRepository->update([ ProductAttributeValue::$attributeTypeFields[$attribute->type] => $data[$attribute->code] diff --git a/packages/Webkul/Product/src/Type/Grouped.php b/packages/Webkul/Product/src/Type/Grouped.php index 848f58b7e..3515f13db 100644 --- a/packages/Webkul/Product/src/Type/Grouped.php +++ b/packages/Webkul/Product/src/Type/Grouped.php @@ -178,9 +178,9 @@ class Grouped extends AbstractType $product = $this->productRepository->find($productId); $cartProducts = $product->getTypeInstance()->prepareForCart([ - 'product_id' => $productId, - 'quantity' => $qty, - ]); + 'product_id' => $productId, + 'quantity' => $qty, + ]); if (is_string($cartProducts)) { return $cartProducts; diff --git a/packages/Webkul/Rule/src/Helpers/Validator.php b/packages/Webkul/Rule/src/Helpers/Validator.php index 65e4b415c..067988e54 100644 --- a/packages/Webkul/Rule/src/Helpers/Validator.php +++ b/packages/Webkul/Rule/src/Helpers/Validator.php @@ -39,8 +39,9 @@ class Validator $validConditionCount++; } } else { - if ($this->validateObject($condition, $entity)) + if ($this->validateObject($condition, $entity)) { return true; + } } } @@ -96,14 +97,14 @@ class Validator case 'product': if ($attributeCode == 'category_ids') { $value = $entity->product - ? $entity->product->categories()->pluck('id')->toArray() - : $entity->categories()->pluck('id')->toArray(); + ? $entity->product->categories()->pluck('id')->toArray() + : $entity->categories()->pluck('id')->toArray(); return $value; } else { $value = $entity->product - ? $entity->product->{$attributeCode} - : $entity->{$attributeCode}; + ? $entity->product->{$attributeCode} + : $entity->{$attributeCode}; if (! in_array($condition['attribute_type'], ['multiselect', 'checkbox'])) { return $value; diff --git a/packages/Webkul/Sales/src/Models/DownloadableLinkPurchased.php b/packages/Webkul/Sales/src/Models/DownloadableLinkPurchased.php index 6851bd2e8..d769f2d29 100644 --- a/packages/Webkul/Sales/src/Models/DownloadableLinkPurchased.php +++ b/packages/Webkul/Sales/src/Models/DownloadableLinkPurchased.php @@ -11,7 +11,20 @@ class DownloadableLinkPurchased extends Model implements DownloadableLinkPurchas { protected $table = 'downloadable_link_purchased'; - protected $fillable = ['product_name', 'name', 'url', 'file', 'file_name', 'type', 'download_bought', 'download_used', 'status', 'customer_id', 'order_id', 'order_item_id']; + protected $fillable = [ + 'product_name', + 'name', + 'url', + 'file', + 'file_name', + 'type', + 'download_bought', + 'download_used', + 'status', + 'customer_id', + 'order_id', + 'order_item_id', + ]; /** * Get the customer record associated with the item. diff --git a/packages/Webkul/Sales/src/Repositories/InvoiceItemRepository.php b/packages/Webkul/Sales/src/Repositories/InvoiceItemRepository.php index 40d082103..17acbaafa 100755 --- a/packages/Webkul/Sales/src/Repositories/InvoiceItemRepository.php +++ b/packages/Webkul/Sales/src/Repositories/InvoiceItemRepository.php @@ -38,8 +38,8 @@ class InvoiceItemRepository extends Repository } $orderedInventory = $data['product']->ordered_inventories() - ->where('channel_id', $data['invoice']->order->channel->id) - ->first(); + ->where('channel_id', $data['invoice']->order->channel->id) + ->first(); if ($orderedInventory) { if (($orderedQty = $orderedInventory->qty - $data['qty']) < 0) { @@ -50,10 +50,10 @@ class InvoiceItemRepository extends Repository } $inventories = $data['product']->inventories() - ->where('vendor_id', $data['vendor_id']) - ->whereIn('inventory_source_id', $data['invoice']->order->channel->inventory_sources()->pluck('id')) - ->orderBy('qty', 'desc') - ->get(); + ->where('vendor_id', $data['vendor_id']) + ->whereIn('inventory_source_id', $data['invoice']->order->channel->inventory_sources()->pluck('id')) + ->orderBy('qty', 'desc') + ->get(); foreach ($inventories as $key => $inventory) { if ($inventory->qty >= $data['qty']) { diff --git a/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php b/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php index 0fa856351..e639c57b5 100755 --- a/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php +++ b/packages/Webkul/Sales/src/Repositories/InvoiceRepository.php @@ -101,14 +101,14 @@ class InvoiceRepository extends Repository $totalQty = array_sum($data['invoice']['items']); $invoice = $this->model->create([ - 'order_id' => $order->id, - 'total_qty' => $totalQty, - 'state' => 'paid', - 'base_currency_code' => $order->base_currency_code, - 'channel_currency_code' => $order->channel_currency_code, - 'order_currency_code' => $order->order_currency_code, - 'order_address_id' => $order->billing_address->id - ]); + 'order_id' => $order->id, + 'total_qty' => $totalQty, + 'state' => 'paid', + 'base_currency_code' => $order->base_currency_code, + 'channel_currency_code' => $order->channel_currency_code, + 'order_currency_code' => $order->order_currency_code, + 'order_address_id' => $order->billing_address->id + ]); foreach ($data['invoice']['items'] as $itemId => $qty) { if (! $qty) { @@ -122,60 +122,60 @@ class InvoiceRepository extends Repository } $invoiceItem = $this->invoiceItemRepository->create([ - 'invoice_id' => $invoice->id, - 'order_item_id' => $orderItem->id, - 'name' => $orderItem->name, - 'sku' => $orderItem->sku, - 'qty' => $qty, - 'price' => $orderItem->price, - 'base_price' => $orderItem->base_price, - 'total' => $orderItem->price * $qty, - 'base_total' => $orderItem->base_price * $qty, - 'tax_amount' => ( ($orderItem->tax_amount / $orderItem->qty_ordered) * $qty ), - 'base_tax_amount' => ( ($orderItem->base_tax_amount / $orderItem->qty_ordered) * $qty ), - 'discount_amount' => ( ($orderItem->discount_amount / $orderItem->qty_ordered) * $qty ), - 'base_discount_amount' => ( ($orderItem->base_discount_amount / $orderItem->qty_ordered) * $qty ), - 'product_id' => $orderItem->product_id, - 'product_type' => $orderItem->product_type, - 'additional' => $orderItem->additional - ]); + 'invoice_id' => $invoice->id, + 'order_item_id' => $orderItem->id, + 'name' => $orderItem->name, + 'sku' => $orderItem->sku, + 'qty' => $qty, + 'price' => $orderItem->price, + 'base_price' => $orderItem->base_price, + 'total' => $orderItem->price * $qty, + 'base_total' => $orderItem->base_price * $qty, + 'tax_amount' => ( ($orderItem->tax_amount / $orderItem->qty_ordered) * $qty ), + 'base_tax_amount' => ( ($orderItem->base_tax_amount / $orderItem->qty_ordered) * $qty ), + 'discount_amount' => ( ($orderItem->discount_amount / $orderItem->qty_ordered) * $qty ), + 'base_discount_amount' => ( ($orderItem->base_discount_amount / $orderItem->qty_ordered) * $qty ), + 'product_id' => $orderItem->product_id, + 'product_type' => $orderItem->product_type, + 'additional' => $orderItem->additional + ]); if ($orderItem->getTypeInstance()->isComposite()) { foreach ($orderItem->children as $childOrderItem) { $finalQty = $childOrderItem->qty_ordered - ? ($childOrderItem->qty_ordered / $orderItem->qty_ordered) * $qty - : $orderItem->qty_ordered; + ? ($childOrderItem->qty_ordered / $orderItem->qty_ordered) * $qty + : $orderItem->qty_ordered; $this->invoiceItemRepository->create([ - 'invoice_id' => $invoice->id, - 'order_item_id' => $childOrderItem->id, - 'parent_id' => $invoiceItem->id, - 'name' => $childOrderItem->name, - 'sku' => $childOrderItem->sku, - 'qty' => $finalQty, - 'price' => $childOrderItem->price, - 'base_price' => $childOrderItem->base_price, - 'total' => $childOrderItem->price * $finalQty, - 'base_total' => $childOrderItem->base_price * $finalQty, - 'tax_amount' => 0, - 'base_tax_amount' => 0, - 'discount_amount' => 0, - 'base_discount_amount' => 0, - 'product_id' => $childOrderItem->product_id, - 'product_type' => $childOrderItem->product_type, - 'additional' => $childOrderItem->additional - ]); + 'invoice_id' => $invoice->id, + 'order_item_id' => $childOrderItem->id, + 'parent_id' => $invoiceItem->id, + 'name' => $childOrderItem->name, + 'sku' => $childOrderItem->sku, + 'qty' => $finalQty, + 'price' => $childOrderItem->price, + 'base_price' => $childOrderItem->base_price, + 'total' => $childOrderItem->price * $finalQty, + 'base_total' => $childOrderItem->base_price * $finalQty, + 'tax_amount' => 0, + 'base_tax_amount' => 0, + 'discount_amount' => 0, + 'base_discount_amount' => 0, + 'product_id' => $childOrderItem->product_id, + 'product_type' => $childOrderItem->product_type, + 'additional' => $childOrderItem->additional + ]); if ($childOrderItem->product && ! $childOrderItem->getTypeInstance()->isStockable() && $childOrderItem->getTypeInstance()->showQuantityBox()) { $this->invoiceItemRepository->updateProductInventory([ - 'invoice' => $invoice, - 'product' => $childOrderItem->product, - 'qty' => $finalQty, - 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 - ]); + 'invoice' => $invoice, + 'product' => $childOrderItem->product, + 'qty' => $finalQty, + 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 + ]); } $this->orderItemRepository->collectTotals($childOrderItem); @@ -185,11 +185,11 @@ class InvoiceRepository extends Repository && $orderItem->getTypeInstance()->showQuantityBox()) { $this->invoiceItemRepository->updateProductInventory([ - 'invoice' => $invoice, - 'product' => $orderItem->product, - 'qty' => $qty, - 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 - ]); + 'invoice' => $invoice, + 'product' => $orderItem->product, + 'qty' => $qty, + 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 + ]); } $this->orderItemRepository->collectTotals($orderItem); diff --git a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php index a74f68509..9d725403d 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php @@ -123,21 +123,21 @@ class OrderItemRepository extends Repository } $orderedInventory = $item->product->ordered_inventories() - ->where('channel_id', $orderItem->order->channel->id) - ->first(); + ->where('channel_id', $orderItem->order->channel->id) + ->first(); $qty = $item->qty_ordered ?: $item->parent->qty_ordered; if ($orderedInventory) { $orderedInventory->update([ - 'qty' => $orderedInventory->qty + $qty - ]); + 'qty' => $orderedInventory->qty + $qty + ]); } else { $item->product->ordered_inventories()->create([ - 'qty' => $qty, - 'product_id' => $item->product_id, - 'channel_id' => $orderItem->order->channel->id, - ]); + 'qty' => $qty, + 'product_id' => $item->product_id, + 'channel_id' => $orderItem->order->channel->id, + ]); } } } @@ -151,8 +151,8 @@ class OrderItemRepository extends Repository public function returnQtyToProductInventory($orderItem) { $orderedInventory = $orderItem->product->ordered_inventories() - ->where('channel_id', $orderItem->order->channel->id) - ->first(); + ->where('channel_id', $orderItem->order->channel->id) + ->first(); if (! $orderedInventory) { return; diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php index 01a990002..eaa7d80e1 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -199,10 +199,10 @@ class OrderRepository extends Repository 'Length' => 'length', 'Suffix' => 'suffix', ] as $varSuffix => $confKey) - { - $var = "invoiceNumber{$varSuffix}"; - $$var = core()->getConfigData('sales.orderSettings.order_number.order_number_'.$confKey) ?: false; - } + { + $var = "invoiceNumber{$varSuffix}"; + $$var = core()->getConfigData('sales.orderSettings.order_number.order_number_'.$confKey) ?: false; + } $lastOrder = $this->model->orderBy('id', 'desc')->limit(1)->first(); $lastId = $lastOrder ? $lastOrder->id : 0; diff --git a/packages/Webkul/Sales/src/Repositories/RefundItemRepository.php b/packages/Webkul/Sales/src/Repositories/RefundItemRepository.php index 164477fc8..373e5a4c2 100644 --- a/packages/Webkul/Sales/src/Repositories/RefundItemRepository.php +++ b/packages/Webkul/Sales/src/Repositories/RefundItemRepository.php @@ -67,9 +67,9 @@ class RefundItemRepository extends Repository $totalShippedQtyToRefund = $totalShippedQtyToRefund > $shippedQty ? $totalShippedQtyToRefund - $shippedQty : 0; $inventory = $product->inventories() - // ->where('vendor_id', $data['vendor_id']) - ->where('inventory_source_id', $shipmentItem->shipment->inventory_source_id) - ->first(); + // ->where('vendor_id', $data['vendor_id']) + ->where('inventory_source_id', $shipmentItem->shipment->inventory_source_id) + ->first(); $inventory->update(['qty' => $inventory->qty + $shippedQtyToRefund]); } @@ -78,10 +78,10 @@ class RefundItemRepository extends Repository } } elseif ($orderItem->getTypeInstance()->showQuantityBox()) { $inventory = $orderItem->product->inventories() - // ->where('vendor_id', $data['vendor_id']) - ->whereIn('inventory_source_id', $orderItem->order->channel->inventory_sources()->pluck('id')) - ->orderBy('qty', 'desc') - ->first(); + // ->where('vendor_id', $data['vendor_id']) + ->whereIn('inventory_source_id', $orderItem->order->channel->inventory_sources()->pluck('id')) + ->orderBy('qty', 'desc') + ->first(); if ($inventory) { $inventory->update(['qty' => $inventory->qty + $quantity]); @@ -90,8 +90,8 @@ class RefundItemRepository extends Repository if ($quantity) { $orderedInventory = $product->ordered_inventories() - ->where('channel_id', $orderItem->order->channel->id) - ->first(); + ->where('channel_id', $orderItem->order->channel->id) + ->first(); if (! $orderedInventory) { return; diff --git a/packages/Webkul/Sales/src/Repositories/RefundRepository.php b/packages/Webkul/Sales/src/Repositories/RefundRepository.php index b8c2ecfc6..d1a7ae826 100644 --- a/packages/Webkul/Sales/src/Repositories/RefundRepository.php +++ b/packages/Webkul/Sales/src/Repositories/RefundRepository.php @@ -98,19 +98,19 @@ class RefundRepository extends Repository $totalQty = array_sum($data['refund']['items']); $refund = parent::create([ - 'order_id' => $order->id, - 'total_qty' => $totalQty, - 'state' => 'refunded', - 'base_currency_code' => $order->base_currency_code, - 'channel_currency_code' => $order->channel_currency_code, - 'order_currency_code' => $order->order_currency_code, - 'adjustment_refund' => core()->convertPrice($data['refund']['adjustment_refund'], $order->order_currency_code), - 'base_adjustment_refund' => $data['refund']['adjustment_refund'], - 'adjustment_fee' => core()->convertPrice($data['refund']['adjustment_fee'], $order->order_currency_code), - 'base_adjustment_fee' => $data['refund']['adjustment_fee'], - 'shipping_amount' => core()->convertPrice($data['refund']['shipping'], $order->order_currency_code), - 'base_shipping_amount' => $data['refund']['shipping'] - ]); + 'order_id' => $order->id, + 'total_qty' => $totalQty, + 'state' => 'refunded', + 'base_currency_code' => $order->base_currency_code, + 'channel_currency_code' => $order->channel_currency_code, + 'order_currency_code' => $order->order_currency_code, + 'adjustment_refund' => core()->convertPrice($data['refund']['adjustment_refund'], $order->order_currency_code), + 'base_adjustment_refund' => $data['refund']['adjustment_refund'], + 'adjustment_fee' => core()->convertPrice($data['refund']['adjustment_fee'], $order->order_currency_code), + 'base_adjustment_fee' => $data['refund']['adjustment_fee'], + 'shipping_amount' => core()->convertPrice($data['refund']['shipping'], $order->order_currency_code), + 'base_shipping_amount' => $data['refund']['shipping'] + ]); foreach ($data['refund']['items'] as $itemId => $qty) { if (! $qty) { @@ -124,49 +124,49 @@ class RefundRepository extends Repository } $refundItem = $this->refundItemRepository->create([ - 'refund_id' => $refund->id, - 'order_item_id' => $orderItem->id, - 'name' => $orderItem->name, - 'sku' => $orderItem->sku, - 'qty' => $qty, - 'price' => $orderItem->price, - 'base_price' => $orderItem->base_price, - 'total' => $orderItem->price * $qty, - 'base_total' => $orderItem->base_price * $qty, - 'tax_amount' => ( ($orderItem->tax_amount / $orderItem->qty_ordered) * $qty ), - 'base_tax_amount' => ( ($orderItem->base_tax_amount / $orderItem->qty_ordered) * $qty ), - 'discount_amount' => ( ($orderItem->discount_amount / $orderItem->qty_ordered) * $qty ), - 'base_discount_amount' => ( ($orderItem->base_discount_amount / $orderItem->qty_ordered) * $qty ), - 'product_id' => $orderItem->product_id, - 'product_type' => $orderItem->product_type, - 'additional' => $orderItem->additional - ]); + 'refund_id' => $refund->id, + 'order_item_id' => $orderItem->id, + 'name' => $orderItem->name, + 'sku' => $orderItem->sku, + 'qty' => $qty, + 'price' => $orderItem->price, + 'base_price' => $orderItem->base_price, + 'total' => $orderItem->price * $qty, + 'base_total' => $orderItem->base_price * $qty, + 'tax_amount' => ( ($orderItem->tax_amount / $orderItem->qty_ordered) * $qty ), + 'base_tax_amount' => ( ($orderItem->base_tax_amount / $orderItem->qty_ordered) * $qty ), + 'discount_amount' => ( ($orderItem->discount_amount / $orderItem->qty_ordered) * $qty ), + 'base_discount_amount' => ( ($orderItem->base_discount_amount / $orderItem->qty_ordered) * $qty ), + 'product_id' => $orderItem->product_id, + 'product_type' => $orderItem->product_type, + 'additional' => $orderItem->additional + ]); if ($orderItem->getTypeInstance()->isComposite()) { foreach ($orderItem->children as $childOrderItem) { $finalQty = $childOrderItem->qty_ordered - ? ($childOrderItem->qty_ordered / $orderItem->qty_ordered) * $qty - : $orderItem->qty_ordered; + ? ($childOrderItem->qty_ordered / $orderItem->qty_ordered) * $qty + : $orderItem->qty_ordered; $refundItem->child = $this->refundItemRepository->create([ - 'refund_id' => $refund->id, - 'order_item_id' => $childOrderItem->id, - 'parent_id' => $refundItem->id, - 'name' => $childOrderItem->name, - 'sku' => $childOrderItem->sku, - 'qty' => $finalQty, - 'price' => $childOrderItem->price, - 'base_price' => $childOrderItem->base_price, - 'total' => $childOrderItem->price * $finalQty, - 'base_total' => $childOrderItem->base_price * $finalQty, - 'tax_amount' => 0, - 'base_tax_amount' => 0, - 'discount_amount' => 0, - 'base_discount_amount' => 0, - 'product_id' => $childOrderItem->product_id, - 'product_type' => $childOrderItem->product_type, - 'additional' => $childOrderItem->additional - ]); + 'refund_id' => $refund->id, + 'order_item_id' => $childOrderItem->id, + 'parent_id' => $refundItem->id, + 'name' => $childOrderItem->name, + 'sku' => $childOrderItem->sku, + 'qty' => $finalQty, + 'price' => $childOrderItem->price, + 'base_price' => $childOrderItem->base_price, + 'total' => $childOrderItem->price * $finalQty, + 'base_total' => $childOrderItem->base_price * $finalQty, + 'tax_amount' => 0, + 'base_tax_amount' => 0, + 'discount_amount' => 0, + 'base_discount_amount' => 0, + 'product_id' => $childOrderItem->product_id, + 'product_type' => $childOrderItem->product_type, + 'additional' => $childOrderItem->additional + ]); if ($childOrderItem->getTypeInstance()->isStockable() || $childOrderItem->getTypeInstance()->showQuantityBox()) { $this->refundItemRepository->returnQtyToProductInventory($childOrderItem, $finalQty); diff --git a/packages/Webkul/Sales/src/Repositories/ShipmentItemRepository.php b/packages/Webkul/Sales/src/Repositories/ShipmentItemRepository.php index 227dbb493..8d4c9ae8b 100644 --- a/packages/Webkul/Sales/src/Repositories/ShipmentItemRepository.php +++ b/packages/Webkul/Sales/src/Repositories/ShipmentItemRepository.php @@ -36,8 +36,8 @@ class ShipmentItemRepository extends Repository } $orderedInventory = $data['product']->ordered_inventories() - ->where('channel_id', $data['shipment']->order->channel->id) - ->first(); + ->where('channel_id', $data['shipment']->order->channel->id) + ->first(); if ($orderedInventory) { if (($orderedQty = $orderedInventory->qty - $data['qty']) < 0) { @@ -48,9 +48,9 @@ class ShipmentItemRepository extends Repository } $inventory = $data['product']->inventories() - ->where('vendor_id', $data['vendor_id']) - ->where('inventory_source_id', $data['shipment']->inventory_source_id) - ->first(); + ->where('vendor_id', $data['vendor_id']) + ->where('inventory_source_id', $data['shipment']->inventory_source_id) + ->first(); if (! $inventory) { return; diff --git a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php index 067d76c24..f6d3cf4cd 100755 --- a/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php +++ b/packages/Webkul/Sales/src/Repositories/ShipmentRepository.php @@ -89,15 +89,15 @@ class ShipmentRepository extends Repository $order = $this->orderRepository->find($data['order_id']); $shipment = $this->model->create([ - 'order_id' => $order->id, - 'total_qty' => 0, - 'carrier_title' => $data['shipment']['carrier_title'], - 'track_number' => $data['shipment']['track_number'], - 'customer_id' => $order->customer_id, - 'customer_type' => $order->customer_type, - 'order_address_id' => $order->shipping_address->id, - 'inventory_source_id' => $data['shipment']['source'], - ]); + 'order_id' => $order->id, + 'total_qty' => 0, + 'carrier_title' => $data['shipment']['carrier_title'], + 'track_number' => $data['shipment']['track_number'], + 'customer_id' => $order->customer_id, + 'customer_type' => $order->customer_type, + 'order_address_id' => $order->shipping_address->id, + 'inventory_source_id' => $data['shipment']['source'], + ]); $totalQty = 0; @@ -113,20 +113,20 @@ class ShipmentRepository extends Repository $totalQty += $qty; $shipmentItem = $this->shipmentItemRepository->create([ - 'shipment_id' => $shipment->id, - 'order_item_id' => $orderItem->id, - 'name' => $orderItem->name, - 'sku' => $orderItem->getTypeInstance()->getOrderedItem($orderItem)->sku, - 'qty' => $qty, - 'weight' => $orderItem->weight * $qty, - 'price' => $orderItem->price, - 'base_price' => $orderItem->base_price, - 'total' => $orderItem->price * $qty, - 'base_total' => $orderItem->base_price * $qty, - 'product_id' => $orderItem->product_id, - 'product_type' => $orderItem->product_type, - 'additional' => $orderItem->additional, - ]); + 'shipment_id' => $shipment->id, + 'order_item_id' => $orderItem->id, + 'name' => $orderItem->name, + 'sku' => $orderItem->getTypeInstance()->getOrderedItem($orderItem)->sku, + 'qty' => $qty, + 'weight' => $orderItem->weight * $qty, + 'price' => $orderItem->price, + 'base_price' => $orderItem->base_price, + 'total' => $orderItem->price * $qty, + 'base_total' => $orderItem->base_price * $qty, + 'product_id' => $orderItem->product_id, + 'product_type' => $orderItem->product_type, + 'additional' => $orderItem->additional, + ]); if ($orderItem->getTypeInstance()->isComposite()) { foreach ($orderItem->children as $child) { @@ -137,30 +137,30 @@ class ShipmentRepository extends Repository } $this->shipmentItemRepository->updateProductInventory([ - 'shipment' => $shipment, - 'product' => $child->product, - 'qty' => $finalQty, - 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 - ]); + 'shipment' => $shipment, + 'product' => $child->product, + 'qty' => $finalQty, + 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 + ]); $this->orderItemRepository->update(['qty_shipped' => $child->qty_shipped + $finalQty], $child->id); } } else { $this->shipmentItemRepository->updateProductInventory([ - 'shipment' => $shipment, - 'product' => $orderItem->product, - 'qty' => $qty, - 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 - ]); + 'shipment' => $shipment, + 'product' => $orderItem->product, + 'qty' => $qty, + 'vendor_id' => isset($data['vendor_id']) ? $data['vendor_id'] : 0 + ]); } $this->orderItemRepository->update(['qty_shipped' => $orderItem->qty_shipped + $qty], $orderItem->id); } $shipment->update([ - 'total_qty' => $totalQty, - 'inventory_source_name' => $shipment->inventory_source->name - ]); + 'total_qty' => $totalQty, + 'inventory_source_name' => $shipment->inventory_source->name + ]); $this->orderRepository->updateOrderStatus($order); diff --git a/packages/Webkul/Shipping/src/Shipping.php b/packages/Webkul/Shipping/src/Shipping.php index c989d9a0e..26effe710 100755 --- a/packages/Webkul/Shipping/src/Shipping.php +++ b/packages/Webkul/Shipping/src/Shipping.php @@ -46,10 +46,10 @@ class Shipping $this->saveAllShippingRates(); return [ - 'jump_to_section' => 'shipping', - 'shippingMethods' => $this->getGroupedAllShippingRates(), - 'html' => view('shop::checkout.onepage.shipping', ['shippingRateGroups' => $this->getGroupedAllShippingRates()])->render() - ]; + 'jump_to_section' => 'shipping', + 'shippingMethods' => $this->getGroupedAllShippingRates(), + 'html' => view('shop::checkout.onepage.shipping', ['shippingRateGroups' => $this->getGroupedAllShippingRates()])->render() + ]; } /** diff --git a/packages/Webkul/Shop/src/Exceptions/Handler.php b/packages/Webkul/Shop/src/Exceptions/Handler.php index 7e3f86aab..aea627dd0 100644 --- a/packages/Webkul/Shop/src/Exceptions/Handler.php +++ b/packages/Webkul/Shop/src/Exceptions/Handler.php @@ -68,10 +68,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/Shop/src/Http/Controllers/DownloadableProductController.php b/packages/Webkul/Shop/src/Http/Controllers/DownloadableProductController.php index 323c8f6e8..5cf1b2093 100644 --- a/packages/Webkul/Shop/src/Http/Controllers/DownloadableProductController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/DownloadableProductController.php @@ -55,9 +55,9 @@ class DownloadableProductController extends Controller public function download($id) { $downloadableLinkPurchased = $this->downloadableLinkPurchasedRepository->findOneByField([ - 'id' => $id, - 'customer_id' => auth()->guard('customer')->user()->id, - ]); + 'id' => $id, + 'customer_id' => auth()->guard('customer')->user()->id, + ]); if ($downloadableLinkPurchased->status == 'pending') { abort(403); @@ -65,6 +65,7 @@ class DownloadableProductController extends Controller if ($downloadableLinkPurchased->download_bought && ($downloadableLinkPurchased->download_bought - $downloadableLinkPurchased->download_used) <= 0) { + session()->flash('warning', trans('shop::app.customer.account.downloadable_products.download-error')); return redirect()->route('customer.downloadable_products.index'); @@ -74,9 +75,9 @@ class DownloadableProductController extends Controller if ($downloadableLinkPurchased->download_bought) { $this->downloadableLinkPurchasedRepository->update([ - 'download_used' => $downloadableLinkPurchased->download_used + 1, - 'status' => $remainingDownloads <= 0 ? 'expired' : $downloadableLinkPurchased->status - ], $downloadableLinkPurchased->id); + 'download_used' => $downloadableLinkPurchased->download_used + 1, + 'status' => $remainingDownloads <= 0 ? 'expired' : $downloadableLinkPurchased->status + ], $downloadableLinkPurchased->id); } if ($downloadableLinkPurchased->type == 'file') { diff --git a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php index e02e65852..87fe91dc8 100755 --- a/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/OnepageController.php @@ -89,8 +89,8 @@ class OnepageController extends Controller $cart = Cart::getCart(); return response()->json([ - 'html' => view('shop::checkout.total.summary', compact('cart'))->render() - ]); + 'html' => view('shop::checkout.total.summary', compact('cart'))->render() + ]); } /** @@ -330,18 +330,18 @@ class OnepageController extends Controller Cart::collectTotals(); return response()->json([ - 'success' => true, - 'message' => trans('admin::app.promotion.status.coupon-removed'), - 'data' => [ - 'grand_total' => core()->currency(Cart::getCart()->grand_total) - ] - ], 200); + 'success' => true, + 'message' => trans('admin::app.promotion.status.coupon-removed'), + 'data' => [ + 'grand_total' => core()->currency(Cart::getCart()->grand_total) + ] + ], 200); } else { return response()->json([ - 'success' => false, - 'message' => trans('admin::app.promotion.status.coupon-remove-failed'), - 'data' => null - ], 422); + 'success' => false, + 'message' => trans('admin::app.promotion.status.coupon-remove-failed'), + 'data' => null + ], 422); } } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php b/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php index 4b73ca8f2..1e0f31b52 100755 --- a/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php +++ b/packages/Webkul/Shop/src/Mail/SubscriptionEmail.php @@ -31,8 +31,13 @@ class SubscriptionEmail extends Mailable public function build() { return $this->to($this->subscriptionData['email']) - ->subject(trans('shop::app.mail.customer.subscription.subject')) - ->view('shop::emails.customer.subscription-email')->with('data', ['content' => 'You Are Subscribed', 'token' => $this->subscriptionData['token']]); + ->subject(trans('shop::app.mail.customer.subscription.subject')) + ->view('shop::emails.customer.subscription-email') + ->with('data', [ + 'content' => 'You Are Subscribed', + 'token' => $this->subscriptionData['token'] + ] + ); } } \ No newline at end of file diff --git a/packages/Webkul/Tax/src/Helpers/Tax.php b/packages/Webkul/Tax/src/Helpers/Tax.php index fac5dc7ca..cfbaf4007 100644 --- a/packages/Webkul/Tax/src/Helpers/Tax.php +++ b/packages/Webkul/Tax/src/Helpers/Tax.php @@ -16,12 +16,14 @@ class Tax public static function getTaxRatesWithAmount(object $that, bool $asBase = false): array { $taxes = []; - foreach ($that->items as $item) { - $taxRate = (string)round((float)$item->tax_percent, self::TAX_PRECISION); - if (!array_key_exists($taxRate, $taxes)) { + foreach ($that->items as $item) { + $taxRate = (string) round((float) $item->tax_percent, self::TAX_PRECISION); + + if (! array_key_exists($taxRate, $taxes)) { $taxes[$taxRate] = 0; } + $taxes[$taxRate] += $asBase ? $item->base_tax_amount : $item->tax_amount; } @@ -40,9 +42,11 @@ class Tax $taxes = self::getTaxRatesWithAmount($that, $asBase); $result = 0; + foreach ($taxes as $taxRate => $taxAmount) { $result += round($taxAmount, 2); } + return $result; } } \ No newline at end of file diff --git a/packages/Webkul/Tax/src/Models/TaxCategory.php b/packages/Webkul/Tax/src/Models/TaxCategory.php index c38a98010..e2322f758 100755 --- a/packages/Webkul/Tax/src/Models/TaxCategory.php +++ b/packages/Webkul/Tax/src/Models/TaxCategory.php @@ -16,11 +16,15 @@ class TaxCategory extends Model implements TaxCategoryContract protected $table = 'tax_categories'; protected $fillable = [ - 'channel_id' ,'code', 'name' ,'description' + 'channel_id', + 'code', + 'name', + 'description', ]; //for joining the two way pivot table - public function tax_rates() { + public function tax_rates() + { return $this->belongsToMany(TaxRateProxy::modelClass(), 'tax_categories_tax_rates', 'tax_category_id')->withPivot('id'); } } \ No newline at end of file diff --git a/packages/Webkul/Tax/src/Models/TaxMap.php b/packages/Webkul/Tax/src/Models/TaxMap.php index 58efaf659..a74c5fa1f 100755 --- a/packages/Webkul/Tax/src/Models/TaxMap.php +++ b/packages/Webkul/Tax/src/Models/TaxMap.php @@ -18,7 +18,8 @@ class TaxMap extends Model implements TaxMapContract protected $table = 'tax_categories_tax_rates'; protected $fillable = [ - 'tax_category_id', 'tax_rate_id' + 'tax_category_id', + 'tax_rate_id', ]; } \ No newline at end of file diff --git a/packages/Webkul/Tax/src/Models/TaxRate.php b/packages/Webkul/Tax/src/Models/TaxRate.php index 29a3cfdd2..21c5dec59 100755 --- a/packages/Webkul/Tax/src/Models/TaxRate.php +++ b/packages/Webkul/Tax/src/Models/TaxRate.php @@ -17,10 +17,19 @@ class TaxRate extends Model implements TaxRateContract protected $table = 'tax_rates'; protected $fillable = [ - 'identifier', 'is_zip', 'zip_code', 'zip_code', 'zip_from', 'zip_to', 'state', 'country', 'tax_rate' + 'identifier', + 'is_zip', + 'zip_code', + 'zip_code', + 'zip_from', + 'zip_to', + 'state', + 'country', + 'tax_rate' ]; - public function tax_categories() { + public function tax_categories() + { return $this->belongsToMany(TaxCategoryProxy::modelClass(), 'tax_categories_tax_rates', 'tax_rate_id', 'id'); } } \ No newline at end of file diff --git a/packages/Webkul/Theme/src/Exceptions/ThemeAlreadyExists.php b/packages/Webkul/Theme/src/Exceptions/ThemeAlreadyExists.php index d2d27f433..57f76117a 100755 --- a/packages/Webkul/Theme/src/Exceptions/ThemeAlreadyExists.php +++ b/packages/Webkul/Theme/src/Exceptions/ThemeAlreadyExists.php @@ -2,9 +2,10 @@ namespace Webkul\Theme\Exceptions; -class ThemeAlreadyExists extends \Exception { - - public function __construct($theme) { +class ThemeAlreadyExists extends \Exception +{ + public function __construct($theme) + { parent::__construct("Theme {$theme->name} already exists", 1); } } \ No newline at end of file diff --git a/packages/Webkul/Theme/src/Exceptions/ThemeNotFound.php b/packages/Webkul/Theme/src/Exceptions/ThemeNotFound.php index a8aceca61..03f824082 100755 --- a/packages/Webkul/Theme/src/Exceptions/ThemeNotFound.php +++ b/packages/Webkul/Theme/src/Exceptions/ThemeNotFound.php @@ -1,8 +1,9 @@ where(function($collection) use($info) { foreach ($this->completeColumnDetails as $column) { - if ($column['searchable'] == true) { if($this->enableFilterMap && isset($this->filterMap[$column['index']])) { $collection->orWhere($this->filterMap[$column['index']], 'like', '%'.$info['all'].'%'); diff --git a/packages/Webkul/User/src/Database/Seeders/AdminsTableSeeder.php b/packages/Webkul/User/src/Database/Seeders/AdminsTableSeeder.php index f44b043c7..25313ed2c 100755 --- a/packages/Webkul/User/src/Database/Seeders/AdminsTableSeeder.php +++ b/packages/Webkul/User/src/Database/Seeders/AdminsTableSeeder.php @@ -13,15 +13,15 @@ class AdminsTableSeeder extends Seeder DB::table('admins')->delete(); DB::table('admins')->insert([ - 'id' => 1, - 'name' => 'Example', - 'email' => 'admin@example.com', - 'password' => bcrypt('admin123'), - 'api_token' => Str::random(80), - 'created_at' => date('Y-m-d H:i:s'), - 'updated_at' => date('Y-m-d H:i:s'), - 'status' => 1, - 'role_id' => 1 - ]); + 'id' => 1, + 'name' => 'Example', + 'email' => 'admin@example.com', + 'password' => bcrypt('admin123'), + 'api_token' => Str::random(80), + 'created_at' => date('Y-m-d H:i:s'), + 'updated_at' => date('Y-m-d H:i:s'), + 'status' => 1, + 'role_id' => 1 + ]); } } diff --git a/packages/Webkul/User/src/Database/Seeders/RolesTableSeeder.php b/packages/Webkul/User/src/Database/Seeders/RolesTableSeeder.php index 4cb5576b6..4c2e5f30f 100755 --- a/packages/Webkul/User/src/Database/Seeders/RolesTableSeeder.php +++ b/packages/Webkul/User/src/Database/Seeders/RolesTableSeeder.php @@ -15,10 +15,10 @@ class RolesTableSeeder extends Seeder DB::table('roles')->delete(); DB::table('roles')->insert([ - 'id' => 1, - 'name' => 'Administrator', - 'description' => 'Administrator rolem', - 'permission_type' => 'all' - ]); + 'id' => 1, + 'name' => 'Administrator', + 'description' => 'Administrator rolem', + 'permission_type' => 'all' + ]); } } \ No newline at end of file diff --git a/packages/Webkul/User/src/Models/Admin.php b/packages/Webkul/User/src/Models/Admin.php index ae6f5d34c..dcaa8e70d 100755 --- a/packages/Webkul/User/src/Models/Admin.php +++ b/packages/Webkul/User/src/Models/Admin.php @@ -19,7 +19,12 @@ class Admin extends Authenticatable implements AdminContract * @var array */ protected $fillable = [ - 'name', 'email', 'password', 'api_token', 'role_id', 'status', + 'name', + 'email', + 'password', + 'api_token', + 'role_id', + 'status', ]; /** @@ -28,7 +33,9 @@ class Admin extends Authenticatable implements AdminContract * @var array */ protected $hidden = [ - 'password', 'api_token', 'remember_token', + 'password', + 'api_token', + 'remember_token', ]; /** diff --git a/packages/Webkul/User/src/Models/Role.php b/packages/Webkul/User/src/Models/Role.php index fcf095b12..778e4f784 100755 --- a/packages/Webkul/User/src/Models/Role.php +++ b/packages/Webkul/User/src/Models/Role.php @@ -15,7 +15,10 @@ class Role extends Model implements RoleContract * @var array */ protected $fillable = [ - 'name', 'description', 'permission_type', 'permissions', + 'name', + 'description', + 'permission_type', + 'permissions', ]; protected $casts = [ diff --git a/packages/Webkul/Velocity/src/Helpers/Helper.php b/packages/Webkul/Velocity/src/Helpers/Helper.php index 946394679..2650d797c 100644 --- a/packages/Webkul/Velocity/src/Helpers/Helper.php +++ b/packages/Webkul/Velocity/src/Helpers/Helper.php @@ -148,11 +148,12 @@ class Helper extends Review */ public function getCountRating($product) { - $reviews = $product->reviews()->where('status', 'approved') - ->select('rating', DB::raw('count(*) as total')) - ->groupBy('rating') - ->orderBy('rating','desc') - ->get(); + $reviews = $product->reviews() + ->where('status', 'approved') + ->select('rating', DB::raw('count(*) as total')) + ->groupBy('rating') + ->orderBy('rating','desc') + ->get(); $totalReviews = $this->getTotalReviews($product); @@ -192,9 +193,9 @@ class Helper extends Review public function getShopRecentReviews($reviewCount = 4) { $reviews = $this->productReviewRepository->getModel() - ->orderBy('id', 'desc') - ->where('status', 'approved') - ->take($reviewCount)->get(); + ->orderBy('id', 'desc') + ->where('status', 'approved') + ->take($reviewCount)->get(); return $reviews; } diff --git a/packages/Webkul/Velocity/src/Http/Controllers/Admin/ContentController.php b/packages/Webkul/Velocity/src/Http/Controllers/Admin/ContentController.php index 2ae92b3fe..963d8b46b 100644 --- a/packages/Webkul/Velocity/src/Http/Controllers/Admin/ContentController.php +++ b/packages/Webkul/Velocity/src/Http/Controllers/Admin/ContentController.php @@ -70,9 +70,9 @@ class ContentController extends Controller if (isset($params['query']) && $params['query']) { foreach ($this->productRepository->searchProductByAttribute(request()->input('query')) as $row) { $results[] = [ - 'id' => $row->product_id, - 'name' => $row->name, - ]; + 'id' => $row->product_id, + 'name' => $row->name, + ]; } } return response()->json($results); diff --git a/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php b/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php index 427966549..a6852afd6 100644 --- a/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php +++ b/packages/Webkul/Velocity/src/Http/Controllers/Shop/ShopController.php @@ -239,9 +239,9 @@ use Webkul\Velocity\Repositories\Product\ProductRepository as VelocityProductRep 'avgRating' => $avgRatings, 'firstReviewText' => trans('velocity::app.products.be-first-review'), 'addToCartHtml' => view('shop::products.add-to-cart', [ - 'product' => $product, - 'addWishlistClass' => !(isset($list) && $list) ? '' : '', - 'addToCartBtnClass' => !(isset($list) && $list) ? $addToCartBtnClass ?? '' : '' + 'product' => $product, + 'addWishlistClass' => ! (isset($list) && $list) ? '' : '', + 'addToCartBtnClass' => ! (isset($list) && $list) ? $addToCartBtnClass ?? '' : '' ])->render(), ]; } diff --git a/packages/Webkul/Velocity/src/Models/Content.php b/packages/Webkul/Velocity/src/Models/Content.php index 339fbd474..24e7bf580 100644 --- a/packages/Webkul/Velocity/src/Models/Content.php +++ b/packages/Webkul/Velocity/src/Models/Content.php @@ -10,7 +10,16 @@ class Content extends TranslatableModel implements ContentContract protected $table = 'velocity_contents'; - public $translatedAttributes = ['title', 'custom_title', 'custom_heading', 'page_link', 'link_target', 'catalog_type', 'products', 'description']; + public $translatedAttributes = [ + 'title', + 'custom_title', + 'custom_heading', + 'page_link', + 'link_target', + 'catalog_type', + 'products', + 'description' + ]; protected $fillable = ['content_type', 'position', 'status']; diff --git a/packages/Webkul/Velocity/src/Models/ContentTranslation.php b/packages/Webkul/Velocity/src/Models/ContentTranslation.php index 590da9b76..e6d414bdf 100644 --- a/packages/Webkul/Velocity/src/Models/ContentTranslation.php +++ b/packages/Webkul/Velocity/src/Models/ContentTranslation.php @@ -12,7 +12,16 @@ class ContentTranslation extends Model implements ContentTranslationContract public $timestamps = false; - protected $fillable = ['title', 'custom_title', 'custom_heading', 'page_link', 'link_target', 'catalog_type', 'products', 'description']; + protected $fillable = [ + 'title', + 'custom_title', + 'custom_heading', + 'page_link', + 'link_target', + 'catalog_type', + 'products', + 'description' + ]; public function content() { diff --git a/packages/Webkul/Velocity/src/Models/OrderBrands.php b/packages/Webkul/Velocity/src/Models/OrderBrands.php index c08db5620..26293cc61 100644 --- a/packages/Webkul/Velocity/src/Models/OrderBrands.php +++ b/packages/Webkul/Velocity/src/Models/OrderBrands.php @@ -14,7 +14,8 @@ class OrderBrands extends Model implements OrderBrandContract protected $fillable = ['order_item_id','order_id','product_id','brand']; - public function getBrands() { + public function getBrands() + { return $this->belongsTo(AttributeOptionProxy::modelClass() , 'brand'); } diff --git a/packages/Webkul/Velocity/src/Repositories/Product/ProductRepository.php b/packages/Webkul/Velocity/src/Repositories/Product/ProductRepository.php index 956aa87d8..c2d130ed3 100644 --- a/packages/Webkul/Velocity/src/Repositories/Product/ProductRepository.php +++ b/packages/Webkul/Velocity/src/Repositories/Product/ProductRepository.php @@ -50,19 +50,19 @@ class ProductRepository extends Repository public function getFeaturedProducts($count) { $results = app(ProductFlatRepository::class)->scopeQuery(function($query) { - $channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()); + $channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()); - $locale = request()->get('locale') ?: app()->getLocale(); + $locale = request()->get('locale') ?: app()->getLocale(); - return $query->distinct() - ->addSelect('product_flat.*') - ->where('product_flat.status', 1) - ->where('product_flat.visible_individually', 1) - ->where('product_flat.featured', 1) - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->orderBy('product_id', 'desc'); - })->paginate($count); + return $query->distinct() + ->addSelect('product_flat.*') + ->where('product_flat.status', 1) + ->where('product_flat.visible_individually', 1) + ->where('product_flat.featured', 1) + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->orderBy('product_id', 'desc'); + })->paginate($count); return $results; } @@ -75,19 +75,19 @@ class ProductRepository extends Repository public function getNewProducts($count) { $results = app(ProductFlatRepository::class)->scopeQuery(function($query) { - $channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()); + $channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode()); - $locale = request()->get('locale') ?: app()->getLocale(); + $locale = request()->get('locale') ?: app()->getLocale(); - return $query->distinct() - ->addSelect('product_flat.*') - ->where('product_flat.status', 1) - ->where('product_flat.visible_individually', 1) - ->where('product_flat.new', 1) - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->orderBy('product_id', 'desc'); - })->paginate($count); + return $query->distinct() + ->addSelect('product_flat.*') + ->where('product_flat.status', 1) + ->where('product_flat.visible_individually', 1) + ->where('product_flat.new', 1) + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->orderBy('product_id', 'desc'); + })->paginate($count); return $results; } @@ -109,14 +109,14 @@ class ProductRepository extends Repository $locale = request()->get('locale') ?: app()->getLocale(); $query = $query->distinct() - ->addSelect('product_flat.*') - ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') - ->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id') - ->where('product_flat.status', 1) - ->where('product_flat.visible_individually', 1) - ->where('product_flat.channel', $channel) - ->where('product_flat.locale', $locale) - ->whereNotNull('product_flat.url_key'); + ->addSelect('product_flat.*') + ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') + ->leftJoin('product_categories', 'products.id', '=', 'product_categories.product_id') + ->where('product_flat.status', 1) + ->where('product_flat.visible_individually', 1) + ->where('product_flat.channel', $channel) + ->where('product_flat.locale', $locale) + ->whereNotNull('product_flat.url_key'); if ($term) $query->where('product_flat.name', 'like', '%' . urldecode($term) . '%'); @@ -143,9 +143,9 @@ class ProductRepository extends Repository $query = $query->where(function($query1) use($query) { $aliases = [ - 'products' => 'filter_', - 'variants' => 'variant_filter_' - ]; + 'products' => 'filter_', + 'variants' => 'variant_filter_' + ]; foreach($aliases as $table => $alias) { $query1 = $query1->orWhere(function($query2) use ($query, $table, $alias) { @@ -173,7 +173,7 @@ class ProductRepository extends Repository }); } else { $query2->where('product_flat.min_price', '>=', core()->convertToBasePrice(current($temp))) - ->where('product_flat.min_price', '<=', core()->convertToBasePrice(end($temp))); + ->where('product_flat.min_price', '<=', core()->convertToBasePrice(end($temp))); } } });