belongsToMany(PricingCode::class, 'spare_part_pricing_code', 'spare_part_id', 'pricing_code_id') ->withTimestamps(); } public function getQuantityWithoutDocsAttribute(): int { if (array_key_exists('quantity_without_docs', $this->attributes)) { return (int) $this->attributes['quantity_without_docs']; } return parent::getQuantityWithoutDocsAttribute(); } public function getQuantityWithDocsAttribute(): int { if (array_key_exists('quantity_with_docs', $this->attributes)) { return (int) $this->attributes['quantity_with_docs']; } return parent::getQuantityWithDocsAttribute(); } public function getTotalQuantityAttribute(): int { if (array_key_exists('total_quantity', $this->attributes)) { return (int) $this->attributes['total_quantity']; } return parent::getTotalQuantityAttribute(); } }