92 lines
2.1 KiB
PHP
92 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 $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);
|
|
}
|
|
}
|