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.

47 lines
1.1 KiB

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