'integer', 'management_id' => 'integer', 'category_id' => 'integer', 'product_id' => 'integer', 'registration_fee' => 'decimal:2', 'subscription_fee' => 'decimal:2', 'discount_rate' => 'decimal:2', 'created_by' => 'integer', ]; /** * 테넌트 관계 */ public function tenant(): BelongsTo { return $this->belongsTo(Tenant::class); } /** * 영업관리 관계 */ public function management(): BelongsTo { return $this->belongsTo(SalesTenantManagement::class, 'management_id'); } /** * 카테고리 관계 */ public function category(): BelongsTo { return $this->belongsTo(SalesProductCategory::class, 'category_id'); } /** * 상품 관계 */ public function product(): BelongsTo { return $this->belongsTo(SalesProduct::class, 'product_id'); } /** * 등록자 관계 */ public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); } /** * 테넌트별 총 개발비 */ public static function getTotalRegistrationFee(int $tenantId): float { return self::where('tenant_id', $tenantId)->sum('registration_fee') ?? 0; } /** * 테넌트별 총 구독료 */ public static function getTotalSubscriptionFee(int $tenantId): float { return self::where('tenant_id', $tenantId)->sum('subscription_fee') ?? 0; } }