'integer', 'trial_ends_at' => 'datetime', 'expires_at' => 'datetime', 'last_paid_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'deleted_at' => 'datetime', ]; /** * 활성 테넌트만 조회 (삭제되지 않은 모든 테넌트) */ public function scopeActive($query) { return $query->whereNull('deleted_at'); } /** * 관계: 사용자 */ public function users(): HasMany { return $this->hasMany(User::class, 'tenant_id'); } /** * 관계: 부서 */ public function departments(): HasMany { return $this->hasMany(\App\Models\Tenants\Department::class, 'tenant_id'); } /** * 관계: 메뉴 */ public function menus(): HasMany { return $this->hasMany(\App\Models\Commons\Menu::class, 'tenant_id'); } /** * 관계: 역할 */ public function roles(): HasMany { return $this->hasMany(\App\Models\Permissions\Role::class, 'tenant_id'); } /** * 상태 배지 색상 (Blade 뷰에서 사용) */ public function getStatusBadgeColorAttribute(): string { return match($this->tenant_st_code) { 'active' => 'success', 'trial' => 'warning', 'suspended', 'expired' => 'error', default => 'neutral', }; } /** * 상태 한글명 (Blade 뷰에서 사용) */ public function getStatusLabelAttribute(): string { return match($this->tenant_st_code) { 'trial' => '트라이얼', 'active' => '활성', 'suspended' => '정지', 'expired' => '만료', default => $this->tenant_st_code, }; } /** * 결제 유형 한글명 (Blade 뷰에서 사용) */ public function getBillingTypeLabelAttribute(): ?string { if (!$this->billing_tp_code) { return null; } return match($this->billing_tp_code) { 'monthly' => '월간', 'yearly' => '연간', 'free' => '무료', default => $this->billing_tp_code, }; } }