$param['tid'], 'module' => $param['m']])->select(); // 获取所有admin_id $adminIds = array_unique(array_column($contents->toArray(), 'admin_id')); // 查询Admin表获取名称 $admins = AdminList::whereIn('id', $adminIds)->column('name', 'id'); $thumb = AdminList::whereIn('id', $adminIds)->column('thumb', 'id'); // 加工数据,添加管理员名称 foreach ($contents as $content) { $content['name'] = $admins[$content['admin_id']] ?? '未知'; $content['thumb'] = $thumb[$content['admin_id']] ?? '未知'; } return to_assign(0, '', $contents); } //添加修改评论内容 public function add() { $param = get_params(); if (!empty($param['id']) && $param['id'] > 0) { $param['update_time'] = time(); $res = CommentList::where(['admin_id' => $this->uid, 'id' => $param['id']])->strict(false)->field(true)->update($param); if ($res) { add_log('edit', $param['id'], $param); return to_assign(); } } else { $param['create_time'] = time(); $param['admin_id'] = $this->uid; $cid = CommentList::strict(false)->field(true)->insertGetId($param); if ($cid) { add_log('add', $cid, $param); //sendMessage($users,1,['title'=>$param['title'],'action_id'=>$sid]); return to_assign(); } } } //删除 public function delete() { if (request()->isDelete()) { $id = get_params("id"); $res = CommentList::where('id', $id)->strict(false)->field(true)->update(['delete_time' => time()]); if ($res) { add_log('delete', $id); return to_assign(0, "删除成功"); } else { return to_assign(1, "删除失败"); } } else { return to_assign(1, "错误的请求"); } } }