diff --git a/app/AdminAgent/Controllers/ChannelController.php b/app/AdminAgent/Controllers/ChannelController.php new file mode 100644 index 0000000..35d8fcf --- /dev/null +++ b/app/AdminAgent/Controllers/ChannelController.php @@ -0,0 +1,101 @@ +model()->where('agent_id', Admin::user()->id) + ->orderBy('sort')->orderBy('id', 'desc'); + + $grid->column('id')->sortable(); + $grid->column('icon')->image('', 60, 60); + $grid->column('name'); + $grid->column('parent.name'); + $grid->column('sort')->editable()->width(120); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + + $filter->equal('id')->width(2); + $filter->like('name')->width(3); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new Channel(['parent']), function (Show $show) { + //不允许查看非自己的数据 + if ($show->model()->agent_id != Admin::user()->id) { + Admin::exit('数据不存在'); + } + + $show->field('id'); + $show->field('icon')->image('', 80, 80); + $show->field('name'); + $show->field('parent.name'); + $show->field('sort'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new Channel(), function (Form $form) { + //不允许修改非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + $form->display('id'); + $form->image('icon')->uniqueName()->removable(false); + $form->text('name')->required(); + $form->select('pid')->options(\App\Models\Channel::selectOptions())->default(0)->required(); + $form->text('sort')->default(255); + })->saving(function (Form $form) { + //不允许修改非自己的数据 + if ($form->isEditing() && $form->model()->agent_id != Admin::user()->id) { + return $form->response()->error('数据不存在'); + } + + //处理特殊字段 + $form->hidden(['agent_id']); + $form->agent_id = Admin::user()->id; + $form->sort = $form->sort ?? 255; + + //不允许编辑的字段 + $form->ignore(['id', 'deleted_at']); + })->deleting(function (Form $form) { + //不允许删除非自己的数据 + if (array_filter($form->model()->toArray(), fn($v) => $v['agent_id'] != Admin::user()->id)) { + return $form->response()->error('数据不存在'); + } + }); + } +} diff --git a/app/AdminAgent/Repositories/Channel.php b/app/AdminAgent/Repositories/Channel.php new file mode 100644 index 0000000..31b7601 --- /dev/null +++ b/app/AdminAgent/Repositories/Channel.php @@ -0,0 +1,16 @@ +resource('demand_bidding', 'DemandBiddingController'); $router->resource('my_demand', 'MyDemandController'); - - $router->resource('message/list', 'MessageController'); $router->resource('notice/list', 'NoticeController'); $router->resource('agent_info', 'AgentInfoController'); $router->resource('supplier/list', 'SupplierController'); $router->resource('article/list', 'ArticleController'); $router->resource('setting', 'SettingController'); + $router->resource('channel/list', 'ChannelController'); //api $router->any('/api/demand/binding', 'DemandController@binding'); diff --git a/app/Models/Channel.php b/app/Models/Channel.php index f23230b..83e58a7 100644 --- a/app/Models/Channel.php +++ b/app/Models/Channel.php @@ -26,4 +26,9 @@ class Channel extends BaseModel parent::__construct($attributes); $this->timestamps = false; } + + public function parent() + { + return $this->hasOne(self::class, 'id', 'pid'); + } } diff --git a/dcat_admin_ide_helper.php b/dcat_admin_ide_helper.php index 102c0a1..36fa2cd 100644 --- a/dcat_admin_ide_helper.php +++ b/dcat_admin_ide_helper.php @@ -43,6 +43,10 @@ namespace Dcat\Admin { * @property Grid\Column|Collection password * @property Grid\Column|Collection remember_token * @property Grid\Column|Collection username + * @property Grid\Column|Collection display + * @property Grid\Column|Collection sort + * @property Grid\Column|Collection status + * @property Grid\Column|Collection url * @property Grid\Column|Collection about * @property Grid\Column|Collection buy_protocol * @property Grid\Column|Collection reg_protocol @@ -52,11 +56,12 @@ namespace Dcat\Admin { * @property Grid\Column|Collection channel_id * @property Grid\Column|Collection deleted_at * @property Grid\Column|Collection guide_id + * @property Grid\Column|Collection is_rec * @property Grid\Column|Collection original_price + * @property Grid\Column|Collection pictures * @property Grid\Column|Collection price * @property Grid\Column|Collection product_ids * @property Grid\Column|Collection sale - * @property Grid\Column|Collection status * @property Grid\Column|Collection stock * @property Grid\Column|Collection verifier * @property Grid\Column|Collection address @@ -72,11 +77,20 @@ namespace Dcat\Admin { * @property Grid\Column|Collection rate * @property Grid\Column|Collection author * @property Grid\Column|Collection image - * @property Grid\Column|Collection sort * @property Grid\Column|Collection pid * @property Grid\Column|Collection template * @property Grid\Column|Collection end_at * @property Grid\Column|Collection start_at + * @property Grid\Column|Collection bidding_id + * @property Grid\Column|Collection bidding_user_id + * @property Grid\Column|Collection bidding_user_type + * @property Grid\Column|Collection comment + * @property Grid\Column|Collection deadline + * @property Grid\Column|Collection images + * @property Grid\Column|Collection publisher_id + * @property Grid\Column|Collection publisher_type + * @property Grid\Column|Collection state + * @property Grid\Column|Collection demand_id * @property Grid\Column|Collection connection * @property Grid\Column|Collection exception * @property Grid\Column|Collection failed_at @@ -84,7 +98,6 @@ namespace Dcat\Admin { * @property Grid\Column|Collection queue * @property Grid\Column|Collection uuid * @property Grid\Column|Collection photo - * @property Grid\Column|Collection is_read * @property Grid\Column|Collection coupon_id * @property Grid\Column|Collection mobile * @property Grid\Column|Collection num @@ -96,9 +109,6 @@ namespace Dcat\Admin { * @property Grid\Column|Collection verify_code * @property Grid\Column|Collection email * @property Grid\Column|Collection token - * @property Grid\Column|Collection pictures - * @property Grid\Column|Collection url - * @property Grid\Column|Collection picture_ad * @property Grid\Column|Collection channels * @property Grid\Column|Collection money * @property Grid\Column|Collection order_id @@ -140,6 +150,10 @@ namespace Dcat\Admin { * @method Grid\Column|Collection password(string $label = null) * @method Grid\Column|Collection remember_token(string $label = null) * @method Grid\Column|Collection username(string $label = null) + * @method Grid\Column|Collection display(string $label = null) + * @method Grid\Column|Collection sort(string $label = null) + * @method Grid\Column|Collection status(string $label = null) + * @method Grid\Column|Collection url(string $label = null) * @method Grid\Column|Collection about(string $label = null) * @method Grid\Column|Collection buy_protocol(string $label = null) * @method Grid\Column|Collection reg_protocol(string $label = null) @@ -149,11 +163,12 @@ namespace Dcat\Admin { * @method Grid\Column|Collection channel_id(string $label = null) * @method Grid\Column|Collection deleted_at(string $label = null) * @method Grid\Column|Collection guide_id(string $label = null) + * @method Grid\Column|Collection is_rec(string $label = null) * @method Grid\Column|Collection original_price(string $label = null) + * @method Grid\Column|Collection pictures(string $label = null) * @method Grid\Column|Collection price(string $label = null) * @method Grid\Column|Collection product_ids(string $label = null) * @method Grid\Column|Collection sale(string $label = null) - * @method Grid\Column|Collection status(string $label = null) * @method Grid\Column|Collection stock(string $label = null) * @method Grid\Column|Collection verifier(string $label = null) * @method Grid\Column|Collection address(string $label = null) @@ -169,11 +184,20 @@ namespace Dcat\Admin { * @method Grid\Column|Collection rate(string $label = null) * @method Grid\Column|Collection author(string $label = null) * @method Grid\Column|Collection image(string $label = null) - * @method Grid\Column|Collection sort(string $label = null) * @method Grid\Column|Collection pid(string $label = null) * @method Grid\Column|Collection template(string $label = null) * @method Grid\Column|Collection end_at(string $label = null) * @method Grid\Column|Collection start_at(string $label = null) + * @method Grid\Column|Collection bidding_id(string $label = null) + * @method Grid\Column|Collection bidding_user_id(string $label = null) + * @method Grid\Column|Collection bidding_user_type(string $label = null) + * @method Grid\Column|Collection comment(string $label = null) + * @method Grid\Column|Collection deadline(string $label = null) + * @method Grid\Column|Collection images(string $label = null) + * @method Grid\Column|Collection publisher_id(string $label = null) + * @method Grid\Column|Collection publisher_type(string $label = null) + * @method Grid\Column|Collection state(string $label = null) + * @method Grid\Column|Collection demand_id(string $label = null) * @method Grid\Column|Collection connection(string $label = null) * @method Grid\Column|Collection exception(string $label = null) * @method Grid\Column|Collection failed_at(string $label = null) @@ -181,7 +205,6 @@ namespace Dcat\Admin { * @method Grid\Column|Collection queue(string $label = null) * @method Grid\Column|Collection uuid(string $label = null) * @method Grid\Column|Collection photo(string $label = null) - * @method Grid\Column|Collection is_read(string $label = null) * @method Grid\Column|Collection coupon_id(string $label = null) * @method Grid\Column|Collection mobile(string $label = null) * @method Grid\Column|Collection num(string $label = null) @@ -193,9 +216,6 @@ namespace Dcat\Admin { * @method Grid\Column|Collection verify_code(string $label = null) * @method Grid\Column|Collection email(string $label = null) * @method Grid\Column|Collection token(string $label = null) - * @method Grid\Column|Collection pictures(string $label = null) - * @method Grid\Column|Collection url(string $label = null) - * @method Grid\Column|Collection picture_ad(string $label = null) * @method Grid\Column|Collection channels(string $label = null) * @method Grid\Column|Collection money(string $label = null) * @method Grid\Column|Collection order_id(string $label = null) @@ -242,6 +262,10 @@ namespace Dcat\Admin { * @property Show\Field|Collection password * @property Show\Field|Collection remember_token * @property Show\Field|Collection username + * @property Show\Field|Collection display + * @property Show\Field|Collection sort + * @property Show\Field|Collection status + * @property Show\Field|Collection url * @property Show\Field|Collection about * @property Show\Field|Collection buy_protocol * @property Show\Field|Collection reg_protocol @@ -251,11 +275,12 @@ namespace Dcat\Admin { * @property Show\Field|Collection channel_id * @property Show\Field|Collection deleted_at * @property Show\Field|Collection guide_id + * @property Show\Field|Collection is_rec * @property Show\Field|Collection original_price + * @property Show\Field|Collection pictures * @property Show\Field|Collection price * @property Show\Field|Collection product_ids * @property Show\Field|Collection sale - * @property Show\Field|Collection status * @property Show\Field|Collection stock * @property Show\Field|Collection verifier * @property Show\Field|Collection address @@ -271,11 +296,20 @@ namespace Dcat\Admin { * @property Show\Field|Collection rate * @property Show\Field|Collection author * @property Show\Field|Collection image - * @property Show\Field|Collection sort * @property Show\Field|Collection pid * @property Show\Field|Collection template * @property Show\Field|Collection end_at * @property Show\Field|Collection start_at + * @property Show\Field|Collection bidding_id + * @property Show\Field|Collection bidding_user_id + * @property Show\Field|Collection bidding_user_type + * @property Show\Field|Collection comment + * @property Show\Field|Collection deadline + * @property Show\Field|Collection images + * @property Show\Field|Collection publisher_id + * @property Show\Field|Collection publisher_type + * @property Show\Field|Collection state + * @property Show\Field|Collection demand_id * @property Show\Field|Collection connection * @property Show\Field|Collection exception * @property Show\Field|Collection failed_at @@ -283,7 +317,6 @@ namespace Dcat\Admin { * @property Show\Field|Collection queue * @property Show\Field|Collection uuid * @property Show\Field|Collection photo - * @property Show\Field|Collection is_read * @property Show\Field|Collection coupon_id * @property Show\Field|Collection mobile * @property Show\Field|Collection num @@ -295,9 +328,6 @@ namespace Dcat\Admin { * @property Show\Field|Collection verify_code * @property Show\Field|Collection email * @property Show\Field|Collection token - * @property Show\Field|Collection pictures - * @property Show\Field|Collection url - * @property Show\Field|Collection picture_ad * @property Show\Field|Collection channels * @property Show\Field|Collection money * @property Show\Field|Collection order_id @@ -339,6 +369,10 @@ namespace Dcat\Admin { * @method Show\Field|Collection password(string $label = null) * @method Show\Field|Collection remember_token(string $label = null) * @method Show\Field|Collection username(string $label = null) + * @method Show\Field|Collection display(string $label = null) + * @method Show\Field|Collection sort(string $label = null) + * @method Show\Field|Collection status(string $label = null) + * @method Show\Field|Collection url(string $label = null) * @method Show\Field|Collection about(string $label = null) * @method Show\Field|Collection buy_protocol(string $label = null) * @method Show\Field|Collection reg_protocol(string $label = null) @@ -348,11 +382,12 @@ namespace Dcat\Admin { * @method Show\Field|Collection channel_id(string $label = null) * @method Show\Field|Collection deleted_at(string $label = null) * @method Show\Field|Collection guide_id(string $label = null) + * @method Show\Field|Collection is_rec(string $label = null) * @method Show\Field|Collection original_price(string $label = null) + * @method Show\Field|Collection pictures(string $label = null) * @method Show\Field|Collection price(string $label = null) * @method Show\Field|Collection product_ids(string $label = null) * @method Show\Field|Collection sale(string $label = null) - * @method Show\Field|Collection status(string $label = null) * @method Show\Field|Collection stock(string $label = null) * @method Show\Field|Collection verifier(string $label = null) * @method Show\Field|Collection address(string $label = null) @@ -368,11 +403,20 @@ namespace Dcat\Admin { * @method Show\Field|Collection rate(string $label = null) * @method Show\Field|Collection author(string $label = null) * @method Show\Field|Collection image(string $label = null) - * @method Show\Field|Collection sort(string $label = null) * @method Show\Field|Collection pid(string $label = null) * @method Show\Field|Collection template(string $label = null) * @method Show\Field|Collection end_at(string $label = null) * @method Show\Field|Collection start_at(string $label = null) + * @method Show\Field|Collection bidding_id(string $label = null) + * @method Show\Field|Collection bidding_user_id(string $label = null) + * @method Show\Field|Collection bidding_user_type(string $label = null) + * @method Show\Field|Collection comment(string $label = null) + * @method Show\Field|Collection deadline(string $label = null) + * @method Show\Field|Collection images(string $label = null) + * @method Show\Field|Collection publisher_id(string $label = null) + * @method Show\Field|Collection publisher_type(string $label = null) + * @method Show\Field|Collection state(string $label = null) + * @method Show\Field|Collection demand_id(string $label = null) * @method Show\Field|Collection connection(string $label = null) * @method Show\Field|Collection exception(string $label = null) * @method Show\Field|Collection failed_at(string $label = null) @@ -380,7 +424,6 @@ namespace Dcat\Admin { * @method Show\Field|Collection queue(string $label = null) * @method Show\Field|Collection uuid(string $label = null) * @method Show\Field|Collection photo(string $label = null) - * @method Show\Field|Collection is_read(string $label = null) * @method Show\Field|Collection coupon_id(string $label = null) * @method Show\Field|Collection mobile(string $label = null) * @method Show\Field|Collection num(string $label = null) @@ -392,9 +435,6 @@ namespace Dcat\Admin { * @method Show\Field|Collection verify_code(string $label = null) * @method Show\Field|Collection email(string $label = null) * @method Show\Field|Collection token(string $label = null) - * @method Show\Field|Collection pictures(string $label = null) - * @method Show\Field|Collection url(string $label = null) - * @method Show\Field|Collection picture_ad(string $label = null) * @method Show\Field|Collection channels(string $label = null) * @method Show\Field|Collection money(string $label = null) * @method Show\Field|Collection order_id(string $label = null) diff --git a/resources/lang/zh_CN/channel.php b/resources/lang/zh_CN/channel.php new file mode 100644 index 0000000..57a5036 --- /dev/null +++ b/resources/lang/zh_CN/channel.php @@ -0,0 +1,16 @@ + [ + 'Channel' => '频道', + 'channel' => '频道', + ], + 'fields' => [ + 'agent_id' => '代理商ID', + 'icon' => '频道图标', + 'name' => '频道名称', + 'pid' => '父级ID', + 'sort' => '排序', + ], + 'options' => [ + ], +];