morphMany(Product::class, null,'model','model_id'); } /** * The offering supplied with this product * * @return \Illuminate\Database\Eloquent\Relations\HasOne */ final public function supplied() { return $this->hasOne(static::SupplierModel,'id','supplier_item_id'); } /* ATTRIBUTES */ /** * The Billing interval that the supplier normally uses for this offering * * @return int */ public function getBillingIntervalAttribute(): int { return static::DefaultBill; } /** * The product contract term is the highest of our defined contract_term (in Products/*) vs the suppliers * contract term (defined in Supplier/*). * * @return int */ public function getContractTermAttribute(): int { return max(Arr::get($this->attributes,'contract_term',0),$this->supplied->contract_term); } }