// +---------------------------------------------------------------------- namespace app\matchmaker\controller; use app\common\Constant; use app\matchmaker\model\MatchmakerUserMatingModel; use app\matchmaker\model\MatchmakerUserModel; use cmf\controller\AdminBaseController; use think\facade\Request; class AdminMatchmakerUserController extends AdminBaseController { public function index() { $data = $this->request->param(); $where = []; if (!empty($data['realname'])) { $where[] = ['realname', 'like', "%{$data['realname']}%"]; } if (!empty($data['mobile'])) { $where[] = ['mobile', 'like', "%{$data['mobile']}%"]; } if (!empty($data['status'])) { $where[] = ['status', '=', $data['status']]; } $this->assign('status', $data['status'] ?? 0); $count = MatchmakerUserModel::with('matchmaker') ->where($where) ->count(); $this->assign('total', $count); $list = MatchmakerUserModel::with('matchmaker') ->where($where) ->order("id DESC") ->paginate(10, false, [ 'query' => Request::param(),//不丢失已存在的url参数 ]); // 获取分页显示 $page = $list->render(); $this->assign('list', $list); $this->assign('page', $page); // 渲染模板输出 return $this->fetch(); } /** * 详情 */ public function show() { //获取id $id = input('param.id'); if (empty($id)) { $this->error(lang('信息不存在或已删除')); } //获取信息 $info = MatchmakerUserModel::get($id, ['matchmaker']); $info['family_text'] = $info['family'] ? implode(',', $info['family']) : '未填写'; $info['have_house'] = Constant::TINYINT[$info['have_house']]; $info['have_car'] = Constant::TINYINT[$info['have_car']]; $info['with_parent_live'] = Constant::TINYINT[$info['with_parent_live']]; $info['want_birth'] = Constant::TINYINT[$info['want_birth']]; if (empty($info)) { $this->error(lang('信息不存在或已删除')); } $this->assign('info', $info); $mating = MatchmakerUserMatingModel::get(['user_id' => $id]); $mating['have_house'] = Constant::COND_TINYINT[$mating['have_house']]; $mating['have_car'] = Constant::COND_TINYINT[$mating['have_car']]; $mating['with_parent_live'] = Constant::COND_TINYINT[$mating['with_parent_live']]; $mating['want_birth'] = Constant::COND_TINYINT[$mating['want_birth']]; if (empty($mating)) { $mating['animal_text'] = ''; } else { $mating['animal_text'] = implode(',', $mating['animal']); } $this->assign('mating', $mating); return $this->fetch(); } }