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.

82 lines
2.2 KiB

7 years ago
4 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 Illuminate\Support\Facades\DB;
  4. class GoodsBrandController extends BaseController
  5. {
  6. public function __construct()
  7. {
  8. parent::__construct();
  9. }
  10. public function index()
  11. {
  12. $data['posts'] = object_to_array(DB::table("goods_brand")->select('id', 'add_time', 'title', 'litpic', 'status', 'listorder', 'cover_img', 'click')->orderBy('id', 'desc')->get());
  13. return view('admin.GoodsBrand.index', $data);
  14. }
  15. public function doadd()
  16. {
  17. $_POST['add_time'] = time();//更新时间
  18. $_POST['click'] = rand(200,500);//点击
  19. unset($_POST["_token"]);
  20. if(isset($_POST['editorValue'])){unset($_POST['editorValue']);}
  21. if(DB::table("goods_brand")->insert($_POST))
  22. {
  23. success_jump('添加成功', route('admin_goodsbrand'));
  24. }
  25. else
  26. {
  27. error_jump('添加失败!请修改后重新添加');
  28. }
  29. }
  30. public function add()
  31. {
  32. return view('admin.GoodsBrand.add');
  33. }
  34. public function edit()
  35. {
  36. if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";}
  37. if(preg_match('/[0-9]*/',$id)){}else{exit;}
  38. $data['id'] = $id;
  39. $data['post'] = object_to_array(DB::table('goods_brand')->where('id', $id)->first(), 1);
  40. return view('admin.GoodsBrand.edit', $data);
  41. }
  42. public function doedit()
  43. {
  44. if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;}
  45. unset($_POST["_token"]);
  46. if(isset($_POST['editorValue'])){unset($_POST['editorValue']);}
  47. if(DB::table('goods_brand')->where('id', $id)->update($_POST))
  48. {
  49. success_jump('修改成功', route('admin_goodsbrand'));
  50. }
  51. else
  52. {
  53. error_jump('修改失败!请修改后重新添加');
  54. }
  55. }
  56. public function del()
  57. {
  58. if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump("删除失败!请重新提交");} //if(preg_match('/[0-9]*/',$id)){}else{exit;}
  59. if(DB::table('goods_brand')->whereIn("id", explode(',', $id))->delete())
  60. {
  61. success_jump('删除成功');
  62. }
  63. else
  64. {
  65. error_jump("删除失败!请重新提交");
  66. }
  67. }
  68. }