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.

91 lines
2.4 KiB

7 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\UserRank;
  6. use App\Common\Helper;
  7. class UserRankController extends CommonController
  8. {
  9. public function __construct()
  10. {
  11. parent::__construct();
  12. }
  13. public function index()
  14. {
  15. $data['posts'] = parent::pageList('user_rank', '', [['listorder', 'asc']]);
  16. if($data['posts'])
  17. {
  18. foreach($data['posts'] as $k=>$v)
  19. {
  20. }
  21. }
  22. return view('admin.userrank.index', $data);
  23. }
  24. public function add()
  25. {
  26. if(Helper::isPostRequest())
  27. {
  28. if(isset($_POST['editorValue'])){unset($_POST['editorValue']);}
  29. unset($_POST["_token"]);
  30. if(DB::table('user_rank')->insert(array_filter($_POST)))
  31. {
  32. success_jump('添加成功!', route('admin_slide'));
  33. }
  34. else
  35. {
  36. error_jump('添加失败!请修改后重新添加');
  37. }
  38. }
  39. return view('admin.userrank.add');
  40. }
  41. public function edit()
  42. {
  43. if(Helper::isPostRequest())
  44. {
  45. if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else{$id="";exit;}
  46. if(isset($_POST['editorValue'])){unset($_POST['editorValue']);}
  47. unset($_POST["_token"]);
  48. if(DB::table('user_rank')->where('id', $id)->update($_POST))
  49. {
  50. success_jump('修改成功!', route('admin_slide'));
  51. }
  52. else
  53. {
  54. error_jump('修改失败!');
  55. }
  56. }
  57. if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";}
  58. if(preg_match('/[0-9]*/',$id)){}else{exit;}
  59. $data['id'] = $id;
  60. $data['post'] = object_to_array(DB::table('user_rank')->where('id', $id)->first(), 1);
  61. return view('admin.userrank.edit', $data);
  62. }
  63. public function del()
  64. {
  65. if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');}
  66. if(DB::table('user_rank')->whereIn("id", explode(',', $id))->delete())
  67. {
  68. success_jump('删除成功');
  69. }
  70. else
  71. {
  72. error_jump('删除失败!请重新提交');
  73. }
  74. }
  75. }