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.

48 lines
1.1 KiB

8 years ago
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Controllers\Admin\CommonController;
  4. use DB;
  5. class GuestbookController extends CommonController
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. }
  11. public function index()
  12. {
  13. $res = '';
  14. $where = function ($query) use ($res) {
  15. if(isset($_REQUEST["keyword"]))
  16. {
  17. $query->where('title', 'like', '%'.$_REQUEST['keyword'].'%');
  18. }
  19. };
  20. $data['posts'] = parent::pageList('guestbook', $where);
  21. return view('admin.guestbook.index', $data);
  22. }
  23. public function edit()
  24. {
  25. $data['post'] = object_to_array(DB::table('guestbook')->where('id', 1)->first());
  26. return view('admin.guestbook.edit', $data);
  27. }
  28. public function del()
  29. {
  30. if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump("删除失败!请重新提交");}
  31. if(DB::table("guestbook")->whereIn("id", explode(',', $id))->delete())
  32. {
  33. success_jump("$id ,删除成功");
  34. }
  35. else
  36. {
  37. error_jump("$id ,删除失败!请重新提交");
  38. }
  39. }
  40. }