PATH:
home
/
lab2454c
/
vaultchip.com
/
platform
/
plugins
/
ecommerce
/
src
/
Repositories
/
Eloquent
<?php namespace Botble\Ecommerce\Repositories\Eloquent; use Botble\Ecommerce\Repositories\Interfaces\DiscountInterface; use Botble\Support\Repositories\Eloquent\RepositoriesAbstract; use Illuminate\Database\Query\Builder; class DiscountRepository extends RepositoriesAbstract implements DiscountInterface { /** * {@inheritDoc} */ public function getAvailablePromotions(array $with = [], bool $forProductSingle = false) { $data = $this->model ->where('type', 'promotion') ->where('start_date', '<=', now()) ->where(function ($query) { /** * @var Builder $query */ return $query ->whereNull('end_date') ->orWhere('end_date', '>=', now()); }) ->where(function ($query) use ($forProductSingle) { /** * @var Builder $query */ return $query ->whereIn('target', ['all-orders', 'amount-minimum-order']) ->orWhere(function ($sub) use ($forProductSingle) { $compare = '>'; if ($forProductSingle) { $compare = '='; } /** * @var Builder $sub */ return $sub ->whereIn('target', ['customer', 'group-products', 'specific-product', 'product-variant']) ->where('product_quantity', $compare, 1); }); }); if ($with) { $data = $data->with($with); } return $this->applyBeforeExecuteQuery($data)->get(); } /** * {@inheritDoc} */ public function getProductPriceBasedOnPromotion(array $productIds = [], array $productCollectionIds = []) { $data = $this->model ->where('type', 'promotion') ->where('start_date', '<=', now()) ->where(function ($query) use ($productIds, $productCollectionIds) { /** * @var Builder $query */ return $query ->where(function ($sub) use ($productIds) { /** * @var Builder $sub */ return $sub ->whereIn('target', ['specific-product', 'product-variant']) ->whereHas('products', function ($whereHas) use ($productIds) { return $whereHas->whereIn('ec_discount_products.product_id', $productIds); }); }) ->orWhere(function ($sub) use ($productCollectionIds) { /** * @var Builder $sub */ return $sub ->where('target', 'group-products') ->whereHas('productCollections', function ($whereHas) use ($productCollectionIds) { return $whereHas->whereIn('ec_discount_product_collections.product_collection_id', $productCollectionIds); }); }) ->orWhere(function ($sub) { /** * @var Builder $sub */ return $sub ->where('target', 'customer') ->whereHas('customers', function ($whereHas) { $customerId = auth('customer')->check() ? auth('customer')->id() : -1; return $whereHas->where('ec_discount_customers.customer_id', $customerId); }); }); }) ->where(function ($query) { /** * @var Builder $query */ return $query ->whereNull('end_date') ->orWhere('end_date', '>=', now()); }) ->where('product_quantity', 1) ->select('ec_discounts.*'); return $this->applyBeforeExecuteQuery($data, true)->get(); } }
[-] ProductAttributeSetRepository.php
[edit]
[-] ProductTagRepository.php
[edit]
[-] ProductAttributeRepository.php
[edit]
[-] ReviewRepository.php
[edit]
[-] FlashSaleRepository.php
[edit]
[+]
..
[-] OrderRepository.php
[edit]
[-] CurrencyRepository.php
[edit]
[-] ProductCollectionRepository.php
[edit]
[-] TaxRepository.php
[edit]
[-] ProductCategoryRepository.php
[edit]
[-] OrderProductRepository.php
[edit]
[-] ShipmentRepository.php
[edit]
[-] ShippingRuleRepository.php
[edit]
[-] ShipmentHistoryRepository.php
[edit]
[-] WishlistRepository.php
[edit]
[-] DiscountRepository.php
[edit]
[-] OrderAddressRepository.php
[edit]
[-] CustomerRepository.php
[edit]
[-] AddressRepository.php
[edit]
[-] ShippingRuleItemRepository.php
[edit]
[-] OrderHistoryRepository.php
[edit]
[-] ProductVariationItemRepository.php
[edit]
[-] GroupedProductRepository.php
[edit]
[-] StoreLocatorRepository.php
[edit]
[-] BrandRepository.php
[edit]
[-] ProductVariationRepository.php
[edit]
[-] ProductRepository.php
[edit]
[-] ProductLabelRepository.php
[edit]
[-] ShippingRepository.php
[edit]