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.

80 lines
1.8 KiB

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. class FriendlinkController extends CommonController
  6. {
  7. public function __construct()
  8. {
  9. parent::__construct();
  10. }
  11. public function index()
  12. {
  13. $posts = parent::pageList('friendlink');
  14. $data['posts'] = $posts;
  15. return view('admin.friendlink.index', $data);
  16. }
  17. public function add()
  18. {
  19. return view('admin.friendlink.add');
  20. }
  21. public function doadd()
  22. {
  23. unset($_POST["_token"]);
  24. if(DB::table('friendlink')->insert($_POST))
  25. {
  26. success_jump('添加成功!', route('admin_friendlink'));
  27. }
  28. else
  29. {
  30. error_jump('添加失败!请修改后重新添加');
  31. }
  32. }
  33. public function edit()
  34. {
  35. if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";}
  36. if(preg_match('/[0-9]*/',$id)){}else{exit;}
  37. $data['id'] = $id;
  38. $data['post'] = object_to_array(DB::table('friendlink')->where('id', $id)->first(), 1);
  39. return view('admin.friendlink.edit', $data);
  40. }
  41. public function doedit()
  42. {
  43. if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;}
  44. unset($_POST["_token"]);
  45. if(DB::table('friendlink')->where('id', $id)->update($_POST))
  46. {
  47. success_jump('修改成功!', route('admin_friendlink'));
  48. }
  49. else
  50. {
  51. error_jump('修改失败!');
  52. }
  53. }
  54. public function del()
  55. {
  56. if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');}
  57. if(DB::table('friendlink')->whereIn("id", explode(',', $id))->delete())
  58. {
  59. success_jump('删除成功');
  60. }
  61. else
  62. {
  63. error_jump('删除失败!请重新提交');
  64. }
  65. }
  66. }