AdminMatchmakerUserController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. if (!empty($data['status'])) {
  30. $where[] = ['status', '=', $data['status']];
  31. }
  32. $this->assign('status', $data['status'] ?? 0);
  33. $count = MatchmakerUserModel::with('matchmaker')
  34. ->where($where)
  35. ->count();
  36. $this->assign('total', $count);
  37. $list = MatchmakerUserModel::with('matchmaker')
  38. ->where($where)
  39. ->order("id DESC")
  40. ->paginate(10, false, [
  41. 'query' => Request::param(),//不丢失已存在的url参数
  42. ]);
  43. // 获取分页显示
  44. $page = $list->render();
  45. $this->assign('list', $list);
  46. $this->assign('page', $page);
  47. // 渲染模板输出
  48. return $this->fetch();
  49. }
  50. /**
  51. * 详情
  52. */
  53. public function show()
  54. {
  55. //获取id
  56. $id = input('param.id');
  57. if (empty($id)) {
  58. $this->error(lang('信息不存在或已删除'));
  59. }
  60. //获取信息
  61. $info = MatchmakerUserModel::get($id, ['matchmaker']);
  62. $info['family_text'] = $info['family'] ? implode(',', $info['family']) : '未填写';
  63. $info['have_house'] = Constant::TINYINT[$info['have_house']];
  64. $info['have_car'] = Constant::TINYINT[$info['have_car']];
  65. $info['with_parent_live'] = Constant::TINYINT[$info['with_parent_live']];
  66. $info['want_birth'] = Constant::TINYINT[$info['want_birth']];
  67. if (empty($info)) {
  68. $this->error(lang('信息不存在或已删除'));
  69. }
  70. $this->assign('info', $info);
  71. $mating = MatchmakerUserMatingModel::get(['user_id' => $id]);
  72. $mating['have_house'] = Constant::COND_TINYINT[$mating['have_house']];
  73. $mating['have_car'] = Constant::COND_TINYINT[$mating['have_car']];
  74. $mating['with_parent_live'] = Constant::COND_TINYINT[$mating['with_parent_live']];
  75. $mating['want_birth'] = Constant::COND_TINYINT[$mating['want_birth']];
  76. if (empty($mating)) {
  77. $mating['animal_text'] = '';
  78. } else {
  79. $mating['animal_text'] = implode(',', $mating['animal']);
  80. }
  81. $this->assign('mating', $mating);
  82. return $this->fetch();
  83. }
  84. }