IndexController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\common\Constant;
  13. use app\common\Fun;
  14. use app\matchmaker\model\MatchmakerUserModel;
  15. class IndexController extends MatchmakerBaseController
  16. {
  17. public function index()
  18. {
  19. return $this->fetch();
  20. }
  21. public function listUser()
  22. {
  23. $param = $this->request->post();
  24. $where = [
  25. ['matchmaker_id', '=', $this->matchmaker['id']],
  26. ];
  27. if (!empty($param['keyword'])) {
  28. $where[] = ['realname|mobile', 'like', "%{$param['keyword']}%"];
  29. }
  30. $list = MatchmakerUserModel::where($where)
  31. ->order('id desc')
  32. ->limit(6)
  33. ->page($param['page'])
  34. ->select();
  35. foreach ($list as $v) {
  36. $v['age'] = Fun::getAgeByBirth($v['birthday']);
  37. $v['sex_text'] = Constant::SEX[$v['sex']];
  38. }
  39. $this->result($list, 1);
  40. }
  41. }