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(); } }