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.1 KiB

8 years ago
7 years ago
7 years ago
8 years ago
7 years ago
8 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use DB;
  4. use App\Common\ReturnData;
  5. use App\Common\Helper;
  6. use Illuminate\Http\Request;
  7. use App\Http\Logic\SlideLogic;
  8. use App\Http\Model\Slide;
  9. class SlideController extends CommonController
  10. {
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. }
  15. public function getLogic()
  16. {
  17. return new SlideLogic();
  18. }
  19. public function index()
  20. {
  21. $where = '';
  22. $posts = $this->getLogic()->getPaginate($where, array('id', 'desc'));
  23. $data['posts'] = $posts;
  24. return view('admin.slide.index', $data);
  25. }
  26. public function add()
  27. {
  28. return view('admin.slide.add');
  29. }
  30. public function doadd()
  31. {
  32. if(isset($_POST['editorValue'])){unset($_POST['editorValue']);}
  33. unset($_POST["_token"]);
  34. if(DB::table('slide')->insert(array_filter($_POST)))
  35. {
  36. success_jump('添加成功!', route('admin_slide'));
  37. }
  38. else
  39. {
  40. error_jump('添加失败!请修改后重新添加');
  41. }
  42. }
  43. public function edit()
  44. {
  45. if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";}
  46. if(preg_match('/[0-9]*/',$id)){}else{exit;}
  47. $data['id'] = $id;
  48. $data['post'] = object_to_array(DB::table('slide')->where('id', $id)->first(), 1);
  49. return view('admin.slide.edit', $data);
  50. }
  51. public function doedit()
  52. {
  53. if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else{$id="";exit;}
  54. if(isset($_POST['editorValue'])){unset($_POST['editorValue']);}
  55. unset($_POST["_token"]);
  56. if(DB::table('slide')->where('id', $id)->update($_POST))
  57. {
  58. success_jump('修改成功!', route('admin_slide'));
  59. }
  60. else
  61. {
  62. error_jump('修改失败!');
  63. }
  64. }
  65. public function del()
  66. {
  67. if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');}
  68. if(DB::table('slide')->whereIn("id", explode(',', $id))->delete())
  69. {
  70. success_jump('删除成功');
  71. }
  72. else
  73. {
  74. error_jump('删除失败!请重新提交');
  75. }
  76. }
  77. }