AdminSelectController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\love\controller;
  12. use app\love\model\UserSelectLogModel;
  13. use cmf\controller\AdminBaseController;
  14. class AdminSelectController extends AdminBaseController
  15. {
  16. /**
  17. * 列表
  18. */
  19. public function index()
  20. {
  21. $list = UserSelectLogModel::with('user1,user2')->order('is_top asc,is_display desc')->paginate(10);
  22. // 获取分页显示
  23. $page = $list->render();
  24. $this->assign('list', $list);
  25. $this->assign('page', $page);
  26. // 渲染模板输出
  27. return $this->fetch();
  28. }
  29. /**
  30. * 置顶
  31. */
  32. public function top()
  33. {
  34. $id = $this->request->param('id');
  35. if (empty($id)) {
  36. $this->error('参数错误');
  37. }
  38. UserSelectLogModel::update(['is_top' => 2], ['is_top' => 1]);
  39. UserSelectLogModel::update(['is_top' => 1, 'is_display' => 1], ['id' => $id]);
  40. $this->success('操作成功');
  41. }
  42. }