You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
885 B
44 lines
885 B
<?php
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class EmailRecord extends SoftDeletesModel
|
|
{
|
|
protected $appends = ['attachment_files'];
|
|
|
|
public function emailTemplate()
|
|
{
|
|
return $this->hasOne(EmailTemplate::class, 'id', 'email_template_id');
|
|
}
|
|
|
|
public function emailRecordUsers()
|
|
{
|
|
return $this->hasMany(EmailRecordUser::class, 'email_record_id', 'id');
|
|
}
|
|
|
|
/**
|
|
* 获取附件文件对象数组
|
|
*/
|
|
public function getAttachmentFilesAttribute()
|
|
{
|
|
if (empty($this->attachments)) {
|
|
return [];
|
|
}
|
|
|
|
$attachmentIds = explode(',', $this->attachments);
|
|
$attachmentIds = array_filter(array_map('trim', $attachmentIds));
|
|
|
|
if (empty($attachmentIds)) {
|
|
return [];
|
|
}
|
|
|
|
return Upload::whereIn('id', $attachmentIds)->get();
|
|
}
|
|
|
|
}
|
|
|