AdminMatchmakerUserController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: Powerless < wzxaini9@gmail.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\matchmaker\controller;
  12. use app\common\Constant;
  13. use app\matchmaker\model\MatchmakerUserMatingModel;
  14. use app\matchmaker\model\MatchmakerUserModel;
  15. use cmf\controller\AdminBaseController;
  16. use think\facade\Request;
  17. class AdminMatchmakerUserController extends AdminBaseController
  18. {
  19. public function index()
  20. {
  21. $data = $this->request->param();
  22. $where = [];
  23. if (!empty($data['realname'])) {
  24. $where[] = ['realname', 'like', "%{$data['realname']}%"];
  25. }
  26. if (!empty($data['mobile'])) {
  27. $where[] = ['mobile', 'like', "%{$data['mobile']}%"];
  28. }
  29. $count = MatchmakerUserModel::with('matchmaker')
  30. ->where($where)
  31. ->count();
  32. $this->assign('total', $count);
  33. $list = MatchmakerUserModel::with('matchmaker')
  34. ->where($where)
  35. ->order("id DESC")
  36. ->paginate(10, false, [
  37. 'query' => Request::param(),//不丢失已存在的url参数
  38. ]);
  39. // 获取分页显示
  40. $page = $list->render();
  41. $this->assign('list', $list);
  42. $this->assign('page', $page);
  43. // 渲染模板输出
  44. return $this->fetch();
  45. }
  46. /**
  47. * 详情
  48. */
  49. public function show()
  50. {
  51. //获取id
  52. $id = input('param.id');
  53. if (empty($id)) {
  54. $this->error(lang('信息不存在或已删除'));
  55. }
  56. //获取信息
  57. $info = MatchmakerUserModel::get($id, ['matchmaker']);
  58. $info['family_text'] = $info['family'] ? implode(',', $info['family']) : '未填写';
  59. $info['have_house'] = Constant::COND_TINYINT[$info['have_house']];
  60. $info['have_car'] = Constant::COND_TINYINT[$info['have_car']];
  61. $info['with_parent_live'] = Constant::COND_TINYINT[$info['with_parent_live']];
  62. if (empty($info)) {
  63. $this->error(lang('信息不存在或已删除'));
  64. }
  65. $this->assign('info', $info);
  66. $mating = MatchmakerUserMatingModel::get(['user_id' => $id]);
  67. $mating['have_house'] = Constant::COND_TINYINT[$mating['have_house']];
  68. $mating['have_car'] = Constant::COND_TINYINT[$mating['have_car']];
  69. $mating['with_parent_live'] = Constant::COND_TINYINT[$mating['with_parent_live']];
  70. $this->assign('mating', $mating);
  71. return $this->fetch();
  72. }
  73. }