list($params); $status_fanyi = array_map(fn($v) => "{{{$v}}}", array_flip(Constants::TICKET_STATUS)); $ossservice = new OssService(); foreach ($result as $key => $value) { $value=$value->toArray(); $value['content'] = str_replace($status_fanyi,$ticket_status,$value['content']); $value['attachment'] = empty($value['attachment'])?[]:unserialize($value['attachment']); foreach ($value['attachment'] as $k => $attachment) { $value['attachment'][$k]['storage_path_full'] = (!empty($attachment))?$ossservice->generatePrivateUrl($attachment['storage_path']):''; } $user = User::where('id', $value['user_id'])->first(); $value['user_name'] = $user?->name; $value['user_avatar'] = $user?->avatar; $result[$key] = $value; } return $result; } public function add(array $data) { try { $data['attachment'] = serialize($data['attachment']); if (empty($data['content'])) { throw new BusinessException('消息内容不能为空'); } return (new ConversationLogic())->add($data); } catch (\Throwable $e) { throw $e; } } public function edit(array $data) { try { Db::beginTransaction(); $data['attachment'] = serialize($data['attachment']); $result = (new ConversationLogic())->edit($data); Db::commit(); return $result; } catch (\Throwable $e) { Db::rollback(); throw $e; } } }