MyController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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: 老猫 <thinkcmf@126.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\matchmaker\controller;
  12. use app\matchmaker\model\MatchmakerModel;
  13. use app\matchmaker\model\MatchmakerUserModel;
  14. class MyController extends MatchmakerBaseController
  15. {
  16. public function index()
  17. {
  18. $data['matchmaker'] = $this->matchmaker;
  19. $data['matchmaker']['avatar'] = cmf_get_image_url($data['matchmaker']['avatar']);
  20. return $this->fetch('', $data);
  21. }
  22. public function info()
  23. {
  24. $data['matchmaker'] = $this->matchmaker;
  25. $data['matchmaker']['avatar'] = cmf_get_image_url($data['matchmaker']['avatar']);
  26. return $this->fetch('', $data);
  27. }
  28. public function infoPost()
  29. {
  30. $data = $this->request->post();
  31. MatchmakerModel::update($data);
  32. $this->success();
  33. }
  34. public function password()
  35. {
  36. return $this->fetch();
  37. }
  38. public function passwordPost()
  39. {
  40. $data = $this->request->post();
  41. if ($data['new_pass'] != $data['re_pass']) {
  42. $this->error('两次密码不一致!');
  43. }
  44. if ($data['old_pass'] != $this->matchmaker['password']) {
  45. $this->error('旧密码错误!');
  46. }
  47. MatchmakerModel::update(['password' => $data['new_pass']], ['id' => $this->matchmaker['id']]);
  48. $this->success();
  49. }
  50. public function statistics()
  51. {
  52. $data = [];
  53. $data['total'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  54. ->count();
  55. $data['sex_man'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  56. ->where('sex', 1)
  57. ->count();
  58. $data['sex_woman'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  59. ->where('sex', 2)
  60. ->count();
  61. $data['education_bkyx'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  62. ->where('education', '本科以下')
  63. ->count();
  64. $data['education_bk'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  65. ->where('education', '本科')
  66. ->count();
  67. $data['education_ss'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  68. ->where('education', '硕士')
  69. ->count();
  70. $data['education_bs'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  71. ->where('education', '博士')
  72. ->count();
  73. $data['marry_wh'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  74. ->where('marry', '未婚')
  75. ->count();
  76. $data['marry_lh'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  77. ->where('marry', '离婚')
  78. ->count();
  79. $data['marry_so'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  80. ->where('marry', '丧偶')
  81. ->count();
  82. $data['status_1'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  83. ->where('status', 1)
  84. ->count();
  85. $data['status_2'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  86. ->where('status', 2)
  87. ->count();
  88. $data['status_3'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  89. ->where('status', 3)
  90. ->count();
  91. $data['status_4'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  92. ->where('status', 4)
  93. ->count();
  94. $data['status_5'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
  95. ->where('status', 5)
  96. ->count();
  97. return view('', $data);
  98. }
  99. }