belongsTo(Invoice::class, 'invoice_id'); } public function product() { return $this->belongsTo(Product::class, 'product_id'); } public function addon() { return $this->belongsTo(Addon::class, 'addon_id'); } // ------------------------------------------------------------------------- // Helpers // ------------------------------------------------------------------------- public function getBillingLabelAttribute(): string { return match ((int) $this->months) { 0 => 'Một lần', 1 => 'Hàng tháng', 3 => 'Hàng quý', 6 => 'Nửa năm', 12 => 'Hàng năm', 24 => '2 năm', 36 => '3 năm', default => $this->months . ' tháng', }; } public function getTypeLabelAttribute(): string { return match ($this->type) { 'service' => 'Dịch vụ', 'addon' => 'Addon', 'upgrade' => 'Nâng cấp', default => ucfirst($this->type), }; } }