where(['uid' => $param['uid'], 'delete_time' => 0])->column('project_id'); $map1[] = ['admin_id', '=', $param['uid']]; $map2[] = ['project_id', 'in', $project_ids]; $whereOr =[$map1,$map2]; } if (!empty($param['keywords'])) { $where[] = ['title|content', 'like', '%' . $param['keywords'] . '%']; } $where[] = ['delete_time', '=', 0]; $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; $list = Db::name('ProjectDocument') ->where(function ($query) use ($whereOr) { if (!empty($whereOr)) $query->whereOr($whereOr); }) ->where($where) ->withoutField('content,md_content') ->order('id desc') ->paginate($rows, false, ['query' => $param]) ->each(function ($item, $key) { $item['project_name'] = Db::name('Project')->where(['id' => $item['project_id']])->value('name'); $item['admin_name'] = Db::name('Admin')->where(['id' => $item['admin_id']])->value('name'); $item['create_time'] = date('Y-m-d H:i', $item['create_time']); return $item; }); return $list; } //详情 public function detail($id) { $detail = Db::name('ProjectDocument')->where(['id' => $id])->find(); if (!empty($detail)) { $detail['project_name'] = '-'; if ($detail['project_id'] > 0) { $detail['project_name'] = Db::name('Project')->where(['id' => $detail['project_id']])->value('name'); } $detail['admin_name'] = Db::name('Admin')->where(['id' => $detail['admin_id']])->value('name'); $detail['times'] = time_trans($detail['create_time']); $detail['create_time'] = date('Y-m-d', $detail['create_time']); } return $detail; } }