PATH:
home
/
lab2454c
/
vaultchip.com
/
platform
/
plugins
/
ecommerce
/
src
/
Models
<?php namespace Botble\Ecommerce\Models; use Botble\Base\Events\DeletedContentEvent; use Botble\Base\Models\BaseModel; use Botble\Ecommerce\Services\Products\UpdateDefaultProductService; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; class ProductVariation extends BaseModel { /** * @var string */ protected $table = 'ec_product_variations'; /** * @var array */ protected $fillable = [ 'product_id', 'configurable_product_id', 'is_default', ]; /** * @var bool */ public $timestamps = false; /** * @return HasMany */ public function variationItems() { return $this->hasMany(ProductVariationItem::class, 'variation_id'); } /** * @return BelongsTo */ public function product() { return $this->belongsTo(Product::class, 'product_id')->withDefault(); } /** * @return BelongsTo */ public function configurableProduct() { return $this->belongsTo(Product::class, 'configurable_product_id')->withDefault(); } /** * @return BelongsToMany */ public function productAttributes() { return $this->belongsToMany(ProductAttribute::class, 'ec_product_variation_items', 'variation_id', 'attribute_id'); } protected static function boot() { parent::boot(); self::deleted(function (ProductVariation $variation) { $variation->productAttributes()->detach(); if ($variation->product) { $variation->product->delete(); event(new DeletedContentEvent(PRODUCT_MODULE_SCREEN_NAME, request(), $variation->product)); } }); self::updated(function (ProductVariation $variation) { if ($variation->is_default) { app(UpdateDefaultProductService::class)->execute($variation->product); } }); } }
[-] 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]