public function afterUpdateCallback() { if ($this->isAttributeChanged('price') || $this->isAttributeChanged('currency_code') || $this->isAttributeChanged('quantity_from') || $this->isAttributeChanged('quantity_to')) { $shopProductPriceChange = new ShopProductPriceChange(); $shopProductPriceChange->price = $this->price; $shopProductPriceChange->currency_code = $this->currency_code; $shopProductPriceChange->quantity_from = $this->quantity_from; $shopProductPriceChange->quantity_to = $this->quantity_to; if ($shopProductPriceChange->save()) { $shopProductPriceChange->link('shopProductPrice', $this); } } }