From 97f760618bf8191168b26a0bf9ef098b01a7ce95 Mon Sep 17 00:00:00 2001 From: liapples Date: Mon, 23 Aug 2021 00:11:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=90=86=E5=95=86?= =?UTF-8?q?=E7=80=91=E5=B8=83=E6=B5=81=E5=86=85=E5=B5=8C=E5=B9=BF=E5=91=8A?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MySQL_change.sql | 16 ++++ .../Controllers/WaterfallAdController.php | 93 +++++++++++++++++++ app/AdminAgent/Repositories/WaterfallAd.php | 16 ++++ app/AdminAgent/routes.php | 1 + app/Models/WaterfallAd.php | 14 +++ resources/lang/zh_CN/waterfall-ad.php | 14 +++ 6 files changed, 154 insertions(+) create mode 100644 app/AdminAgent/Controllers/WaterfallAdController.php create mode 100644 app/AdminAgent/Repositories/WaterfallAd.php create mode 100644 app/Models/WaterfallAd.php create mode 100644 resources/lang/zh_CN/waterfall-ad.php diff --git a/MySQL_change.sql b/MySQL_change.sql index bbf0c8d..f2ba995 100644 --- a/MySQL_change.sql +++ b/MySQL_change.sql @@ -98,3 +98,19 @@ ALTER TABLE `slides` CHANGE COLUMN `url` `picture` VARCHAR(255) NOT NULL COMMENT '轮播图地址' COLLATE 'utf8_general_ci' AFTER `title`, ADD COLUMN `type` TINYINT NOT NULL DEFAULT '0' COMMENT '链接类型,0:链接产品详情;1:链接到webview url' AFTER `sort`, ADD COLUMN `url` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '链接地址' AFTER `type`; + +# 23:43 ‎2021/‎08/‎22 +CREATE TABLE `waterfall_ads` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `agent_id` INT(11) NOT NULL COMMENT '代理商ID', + `picture` VARCHAR(255) NOT NULL COMMENT '广告图片' COLLATE 'utf8_general_ci', + `agent_product_id` INT(11) NOT NULL COMMENT '链接到产品', + `created_at` TIMESTAMP NULL DEFAULT NULL, + `updated_at` TIMESTAMP NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE, + INDEX `agent_id` (`agent_id`) USING BTREE +) +COMMENT='瀑布流内嵌广告' +COLLATE='utf8_general_ci' +ENGINE=InnoDB +; diff --git a/app/AdminAgent/Controllers/WaterfallAdController.php b/app/AdminAgent/Controllers/WaterfallAdController.php new file mode 100644 index 0000000..6271d66 --- /dev/null +++ b/app/AdminAgent/Controllers/WaterfallAdController.php @@ -0,0 +1,93 @@ +disableFilterButton(); + + $grid->model()->where('agent_id', Admin::user()->id); + + $grid->column('id')->sortable(); + $grid->column('picture'); + $grid->column('agent_product_id'); + $grid->column('created_at'); + $grid->column('updated_at')->sortable(); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + + $filter->equal('id'); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new WaterfallAd(), function (Show $show) { + //不允许查看非自己的数据 + if ($show->model()->agent_id != Admin::user()->id) { + Admin::exit('数据不存在'); + } + + $show->field('id'); + $show->field('picture'); + $show->field('agent_product_id'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new WaterfallAd(), function (Form $form) { + //不允许查看非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + $form->display('id'); + $form->text('picture'); + $form->text('agent_product_id'); + })->saving(function (Form $form) { + //不允许修改非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + + })->deleting(function (Form $form) { + //不允许删除非自己的数据 + if ($form->model()[0]['agent_id'] != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + }); + } +} diff --git a/app/AdminAgent/Repositories/WaterfallAd.php b/app/AdminAgent/Repositories/WaterfallAd.php new file mode 100644 index 0000000..20e0745 --- /dev/null +++ b/app/AdminAgent/Repositories/WaterfallAd.php @@ -0,0 +1,16 @@ +resource('order/list', 'OrderController'); $router->resource('slide/list', 'SlideController'); $router->resource('special/list', 'SpecialController'); + $router->resource('waterfall_ad/list', 'WaterfallAdController'); }); diff --git a/app/Models/WaterfallAd.php b/app/Models/WaterfallAd.php new file mode 100644 index 0000000..402321f --- /dev/null +++ b/app/Models/WaterfallAd.php @@ -0,0 +1,14 @@ + [ + 'WaterfallAd' => '产品列表内嵌广告', + 'waterfall-ad' => '产品列表内嵌广告', + ], + 'fields' => [ + 'agent_id' => '代理商ID', + 'picture' => '广告图片', + 'agent_product_id' => '链接到产品', + ], + 'options' => [ + ], +];