Files
sam-manage/app/Models/Sales/SalesProspectConsultation.php
김보곤 ca50f65124 feat: [database] codebridge DB 분리 - 118개 MNG 전용 테이블 connection 설정
- config/database.php에 codebridge connection 추가
- 78개 MNG 전용 모델에 $connection = 'codebridge' 설정
  - Admin (15): PM, 로드맵, API Explorer
  - Sales (16): 영업파트너, 수수료, 가망고객
  - Finance (9): 법인카드, 자금관리, 홈택스
  - Barobill (12): 은행/카드 동기화 관리
  - Interview (1), ESign (6), Equipment (2)
  - AI (3), Audit (3), 기타 (11)
2026-03-07 11:27:18 +09:00

93 lines
2.1 KiB
PHP

<?php
namespace App\Models\Sales;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class SalesProspectConsultation extends Model
{
use SoftDeletes;
protected $connection = 'codebridge';
protected $table = 'sales_prospect_consultations';
protected $fillable = [
'prospect_id',
'manager_id',
'scenario_type',
'step_id',
'log_text',
'audio_file_path',
'attachment_paths',
'consultation_type',
];
protected $casts = [
'step_id' => 'integer',
'attachment_paths' => 'array',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
];
/**
* 가망고객
*/
public function prospect(): BelongsTo
{
return $this->belongsTo(SalesProspect::class, 'prospect_id');
}
/**
* 작성자
*/
public function manager(): BelongsTo
{
return $this->belongsTo(SalesManager::class, 'manager_id');
}
/**
* 상담 유형 라벨
*/
public function getConsultationTypeLabelAttribute(): string
{
return match ($this->consultation_type) {
'text' => '텍스트',
'audio' => '음성',
'file' => '파일',
default => $this->consultation_type,
};
}
/**
* 상담 유형별 아이콘 클래스
*/
public function getConsultationTypeIconAttribute(): string
{
return match ($this->consultation_type) {
'text' => 'fa-comment',
'audio' => 'fa-microphone',
'file' => 'fa-paperclip',
default => 'fa-question',
};
}
/**
* 첨부파일 개수
*/
public function getAttachmentCountAttribute(): int
{
return is_array($this->attachment_paths) ? count($this->attachment_paths) : 0;
}
/**
* 음성 파일 존재 여부
*/
public function getHasAudioAttribute(): bool
{
return ! empty($this->audio_file_path);
}
}