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.

95 lines
2.5 KiB

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