You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.6 KiB

8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
8 years ago
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Admin\CommonController;
  4. use DB;
  5. use App\Http\Model\User;
  6. class UserController extends CommonController
  7. {
  8. public function __construct()
  9. {
  10. parent::__construct();
  11. }
  12. public function index()
  13. {
  14. $posts = parent::pageList('user');
  15. if($posts)
  16. {
  17. foreach($posts as $k=>$v)
  18. {
  19. $posts[$k]->sex_text = User::getSexText(['sex'=>$v->sex]);
  20. $posts[$k]->status_text = User::getStatusText(['status'=>$v->status]);
  21. }
  22. }
  23. $data['posts'] = $posts;
  24. return view('admin.user.index', $data);
  25. }
  26. //会员账户记录
  27. public function money()
  28. {
  29. $where = '';
  30. if(isset($_REQUEST["user_id"]))
  31. {
  32. $where['user_id'] = $_REQUEST["user_id"];
  33. }
  34. $posts = parent::pageList('user_money',$where);
  35. if($posts)
  36. {
  37. foreach($posts as $k=>$v)
  38. {
  39. $posts[$k]->user = DB::table('user')->where('id', $v->user_id)->first();
  40. }
  41. }
  42. $data['posts'] = $posts;
  43. return view('admin.user.money', $data);
  44. }
  45. public function add()
  46. {
  47. return view('admin.user.add');
  48. }
  49. public function doadd()
  50. {
  51. unset($_POST["_token"]);
  52. if(DB::table('user')->insert($_POST))
  53. {
  54. success_jump('添加成功!', route('admin_user'));
  55. }
  56. else
  57. {
  58. error_jump('添加失败!请修改后重新添加');
  59. }
  60. }
  61. public function edit()
  62. {
  63. if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";}
  64. if(preg_match('/[0-9]*/',$id)){}else{exit;}
  65. $data['id'] = $id;
  66. $data['post'] = object_to_array(DB::table('user')->where('id', $id)->first(), 1);
  67. return view('admin.user.edit', $data);
  68. }
  69. public function doedit()
  70. {
  71. if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;}
  72. unset($_POST["_token"]);
  73. if(DB::table('user')->where('id', $id)->update($_POST))
  74. {
  75. success_jump('修改成功!', route('admin_user'));
  76. }
  77. else
  78. {
  79. error_jump('修改失败!');
  80. }
  81. }
  82. public function del()
  83. {
  84. if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');}
  85. if(DB::table('user')->whereIn("id", explode(',', $id))->update(['status' => 2]))
  86. {
  87. success_jump('删除成功');
  88. }
  89. else
  90. {
  91. error_jump('删除失败!请重新提交');
  92. }
  93. }
  94. }