MainController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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: 小夏 < 449134904@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\controller;
  12. use app\admin\model\UserModel;
  13. use app\common\Fun;
  14. use app\love\model\UserAuthModel;
  15. use cmf\controller\AdminBaseController;
  16. use think\Db;
  17. class MainController extends AdminBaseController
  18. {
  19. /**
  20. * 后台欢迎页
  21. */
  22. public function index()
  23. {
  24. $user = [];
  25. $user_where = [
  26. ['user_type', '=', 2],
  27. ['is_complete', '=', 1],
  28. ];
  29. $user['total'] = UserModel::where($user_where)->count();
  30. $user['man'] = UserModel::where($user_where)->where('sex',1)->count();
  31. $user['woman'] = UserModel::where($user_where)->where('sex',2)->count();
  32. $config = Db::name('config')->find();
  33. $this->assign('user',$user);
  34. $this->assign('config',$config);
  35. return $this->fetch();
  36. }
  37. public function dashboardWidget()
  38. {
  39. $dashboardWidgets = [];
  40. $widgets = $this->request->param('widgets/a');
  41. if (!empty($widgets)) {
  42. foreach ($widgets as $widget) {
  43. if ($widget['is_system']) {
  44. array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 1]);
  45. } else {
  46. array_push($dashboardWidgets, ['name' => $widget['name'], 'is_system' => 0]);
  47. }
  48. }
  49. }
  50. cmf_set_option('admin_dashboard_widgets', $dashboardWidgets, true);
  51. $this->success('更新成功!');
  52. }
  53. }