Files
sam-manage/app/Models/Sales/SalesProspectConsultation.php
김보곤 b831979153 feat: [database] codebridge DB 분리 재적용 - 55개 MNG 전용 모델만 설정
- API 사용 테이블 22개(23개 모델) 제외하고 55개 모델만 $connection = 'codebridge' 적용
- config/database.php에 codebridge connection 재추가
- 제외 대상: Barobill 12개, ESign 4개, Audit 2개, DevTools 1개, System 2개, HR 1개
2026-03-09 20:02:04 +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);
}
}