PATH:
home
/
lab2454c
/
vaultchip.com
/
platform
/
plugins
/
ecommerce
/
src
/
Models
<?php namespace Botble\Ecommerce\Models; use Botble\Base\Models\BaseModel; use Illuminate\Database\Eloquent\Relations\BelongsToMany; class Discount extends BaseModel { /** * @var string */ protected $table = 'ec_discounts'; /** * @var array */ protected $fillable = [ 'title', 'code', 'start_date', 'end_date', 'quantity', 'total_used', 'value', 'type', 'can_use_with_promotion', 'type_option', 'target', 'min_order_price', 'discount_on', 'product_quantity', ]; /** * @var array */ protected $dates = [ 'start_date', 'end_date', 'created_at', 'updated_at', ]; /** * @return bool */ public function isExpired() { if ($this->end_date && strtotime($this->end_date) < strtotime(now()->toDateTimeString())) { return true; } return false; } /** * @return BelongsToMany */ public function productCollections() { return $this->belongsToMany( ProductCollection::class, 'ec_discount_product_collections', 'discount_id', 'product_collection_id' ); } /** * @return BelongsToMany */ public function customers() { return $this->belongsToMany(Customer::class, 'ec_discount_customers', 'discount_id', 'customer_id'); } /** * @return BelongsToMany */ public function products() { return $this->belongsToMany(Product::class, 'ec_discount_products', 'discount_id', 'product_id'); } protected static function boot() { parent::boot(); static::deleting(function (Discount $discount) { $discount->productCollections()->detach(); $discount->customers()->detach(); $discount->products()->detach(); }); } }
[-] ProductLabelTranslation.php
[edit]
[-] Review.php
[edit]
[-] ShippingRule.php
[edit]
[+]
..
[-] Discount.php
[edit]
[-] Address.php
[edit]
[-] GroupedProduct.php
[edit]
[-] StoreLocator.php
[edit]
[-] ProductAttribute.php
[edit]
[-] OrderHistory.php
[edit]
[-] ShipmentHistory.php
[edit]
[-] ProductVariation.php
[edit]
[-] DiscountProductCollection.php
[edit]
[-] ProductAttributeTranslation.php
[edit]
[-] ProductCollection.php
[edit]
[-] Order.php
[edit]
[-] Wishlist.php
[edit]
[-] ProductTag.php
[edit]
[-] Customer.php
[edit]
[-] BrandTranslation.php
[edit]
[-] Tax.php
[edit]
[-] FlashSale.php
[edit]
[-] ProductAttributeSetTranslation.php
[edit]
[-] ProductCollectionTranslation.php
[edit]
[-] OrderAddress.php
[edit]
[-] DiscountProduct.php
[edit]
[-] DiscountCustomer.php
[edit]
[-] Shipping.php
[edit]
[-] Brand.php
[edit]
[-] ProductTranslation.php
[edit]
[-] ProductVariationItem.php
[edit]
[-] Product.php
[edit]
[-] ProductLabel.php
[edit]
[-] OrderProduct.php
[edit]
[-] Currency.php
[edit]
[-] ShippingRuleItem.php
[edit]
[-] ProductAttributeSet.php
[edit]
[-] FlashSaleTranslation.php
[edit]
[-] ProductCategory.php
[edit]
[-] Shipment.php
[edit]
[-] ProductCategoryTranslation.php
[edit]