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

9 months ago
<?php
namespace App\Models;
use Illuminate\Support\Facades\Cache;
class EmailRecord extends SoftDeletesModel
{
3 months ago
protected $appends = ['attachment_files'];
9 months ago
public function emailTemplate()
{
return $this->hasOne(EmailTemplate::class, 'id', 'email_template_id');
}
9 months ago
public function emailRecordUsers()
{
return $this->hasMany(EmailRecordUser::class, 'email_record_id', 'id');
}
9 months ago
3 months ago
/**
* 获取附件文件对象数组
*/
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();
}
9 months ago
}