feat:영업담당자 User 모듈 통합 및 승인 시스템 구현
- SalesManagerController: User 시스템 기반으로 재구현 - SalesManagerService: 영업담당자 CRUD, 승인/반려 로직 - SalesManagerDocument: 멀티파일 업로드 모델 - User 모델에 parent, approval 관계 및 메서드 추가 - SalesRoleSeeder: 영업 역할 시더 (sales_operator, sales_admin, sales_manager) - 뷰 파일 전면 수정 (역할 체크박스, 멀티파일 업로드, 승인/반려 UI) - 라우트 추가 (approve, reject, documents) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,11 @@ class User extends Authenticatable
|
||||
'role',
|
||||
'is_active',
|
||||
'is_super_admin',
|
||||
'parent_id',
|
||||
'approval_status',
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
'rejection_reason',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -62,9 +67,92 @@ protected function casts(): array
|
||||
'is_active' => 'boolean',
|
||||
'is_super_admin' => 'boolean',
|
||||
'must_change_password' => 'boolean',
|
||||
'approved_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 상위 관리자 (영업담당자 계층 구조)
|
||||
*/
|
||||
public function parent(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'parent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 하위 관리자 목록
|
||||
*/
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(User::class, 'parent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인자
|
||||
*/
|
||||
public function approver(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'approved_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* 영업담당자 첨부 서류
|
||||
*/
|
||||
public function salesDocuments(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Sales\SalesManagerDocument::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인 대기 상태인지 확인
|
||||
*/
|
||||
public function isPendingApproval(): bool
|
||||
{
|
||||
return $this->approval_status === 'pending';
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인됨 상태인지 확인
|
||||
*/
|
||||
public function isApproved(): bool
|
||||
{
|
||||
return $this->approval_status === 'approved';
|
||||
}
|
||||
|
||||
/**
|
||||
* 반려됨 상태인지 확인
|
||||
*/
|
||||
public function isRejected(): bool
|
||||
{
|
||||
return $this->approval_status === 'rejected';
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인 상태 라벨
|
||||
*/
|
||||
public function getApprovalStatusLabelAttribute(): string
|
||||
{
|
||||
return match ($this->approval_status) {
|
||||
'pending' => '승인대기',
|
||||
'approved' => '승인완료',
|
||||
'rejected' => '반려',
|
||||
default => $this->approval_status,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인 상태별 색상 클래스
|
||||
*/
|
||||
public function getApprovalStatusColorAttribute(): string
|
||||
{
|
||||
return match ($this->approval_status) {
|
||||
'pending' => 'bg-yellow-100 text-yellow-800',
|
||||
'approved' => 'bg-green-100 text-green-800',
|
||||
'rejected' => 'bg-red-100 text-red-800',
|
||||
default => 'bg-gray-100 text-gray-800',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 관계: 테넌트들 (Many-to-Many via user_tenants)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user