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.

114 lines
2.9 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
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
7 years ago
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use DB;
  4. use App\Common\Helper;
  5. use Illuminate\Http\Request;
  6. use App\Http\Model\Bonus;
  7. use App\Http\Logic\BonusLogic;
  8. class BonusController extends CommonController
  9. {
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. }
  14. public function getLogic()
  15. {
  16. return logic('Bonus');
  17. }
  18. public function index()
  19. {
  20. $res = '';
  21. $where = function ($query) use ($res) {
  22. if(isset($_REQUEST["keyword"]))
  23. {
  24. $query->where('name', 'like', '%'.$_REQUEST['keyword'].'%');
  25. }
  26. if(isset($_REQUEST["id"]))
  27. {
  28. $query->where('typeid', $_REQUEST["id"]);
  29. }
  30. };
  31. $posts = $this->getLogic()->getPaginate($where, array('status', 'asc'));
  32. if($posts)
  33. {
  34. foreach($posts as $k=>$v)
  35. {
  36. }
  37. }
  38. $data['posts'] = $posts;
  39. return view('admin.bonus.index', $data);
  40. }
  41. public function add()
  42. {
  43. if(Helper::isPostRequest())
  44. {
  45. if(isset($_POST['editorValue'])){unset($_POST['editorValue']);}
  46. unset($_POST["_token"]);
  47. if($_POST["start_time"]>=$_POST["end_time"]){error_jump('参数错误');}
  48. if(DB::table('bonus')->insert(array_filter($_POST)))
  49. {
  50. success_jump('添加成功!', route('admin_bonus'));
  51. }
  52. else
  53. {
  54. error_jump('添加失败!请修改后重新添加');
  55. }
  56. }
  57. return view('admin.bonus.add');
  58. }
  59. public function edit()
  60. {
  61. if(Helper::isPostRequest())
  62. {
  63. if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else{$id="";exit;}
  64. if(isset($_POST['editorValue'])){unset($_POST['editorValue']);}
  65. unset($_POST["_token"]);
  66. if($_POST["start_time"]>=$_POST["end_time"]){error_jump('参数错误');}
  67. if(DB::table('bonus')->where('id', $id)->update($_POST))
  68. {
  69. success_jump('修改成功!', route('admin_bonus'));
  70. }
  71. else
  72. {
  73. error_jump('修改失败!');
  74. }
  75. }
  76. if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";}
  77. if(preg_match('/[0-9]*/',$id)){}else{exit;}
  78. $data['id'] = $id;
  79. $data['post'] = object_to_array(DB::table('bonus')->where('id', $id)->first(), 1);
  80. return view('admin.bonus.edit', $data);
  81. }
  82. public function del()
  83. {
  84. if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');}
  85. if(DB::table('bonus')->whereIn("id", explode(',', $id))->delete())
  86. {
  87. success_jump('删除成功');
  88. }
  89. else
  90. {
  91. error_jump('删除失败!请重新提交');
  92. }
  93. }
  94. }