Files
sam-manage/app/Models/Sales/SalesProspectConsultation.php
pro d39028d92a feat:영업관리 모듈 (salesmanagement) Laravel 마이그레이션
레거시 sales 시스템에서 MNG로 마이그레이션:
- 마이그레이션: sales_managers, sales_prospects, sales_records 등 6개 테이블
- 모델: SalesManager, SalesProspect, SalesRecord 등 6개 모델
- 컨트롤러: SalesManagerController, SalesProspectController, SalesRecordController
- 뷰: managers, prospects, records CRUD 화면
- 라우트: /sales/* 경로 추가

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:09:42 +09:00

92 lines
2.0 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 $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);
}
}