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' => [ + ], +];