diff --git a/app/AdminAgent/Controllers/SlideController.php b/app/AdminAgent/Controllers/SlideController.php new file mode 100644 index 0000000..7632f10 --- /dev/null +++ b/app/AdminAgent/Controllers/SlideController.php @@ -0,0 +1,77 @@ +model()->where('agent_id', Admin::user()->id)->orderBy('sort'); + + $grid->column('id')->sortable(); + $grid->column('title'); + $grid->column('url')->image('', 60, 60); + $grid->column('status')->switch(); + $grid->column('sort')->editable()->sortable()->width(120); + + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id'); + + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new Slide(), function (Show $show) { + $show->field('id'); + $show->field('title'); + $show->field('url')->image('', 80, 80); + $show->field('status')->using(['禁用', '启用']); + $show->field('sort'); + $show->field('created_at'); + $show->field('updated_at'); + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new Slide(), function (Form $form) { + $form->display('id'); + $form->text('title'); + $form->image('url')->required()->removable(false); + $form->switch('status')->required(); + $form->text('sort')->required(); + })->saving(function (Form $form) { + //处理特殊字段 + $form->hidden(['agent_id']); + $form->agent_id = Admin::user()->id; + $form->status = $form->status ? 1 : 0; + }); + } +} diff --git a/app/AdminAgent/Repositories/Slide.php b/app/AdminAgent/Repositories/Slide.php new file mode 100644 index 0000000..a7eef5c --- /dev/null +++ b/app/AdminAgent/Repositories/Slide.php @@ -0,0 +1,16 @@ +resource('category/list', 'CategoryController'); $router->resource('user/list', 'UserController'); $router->resource('order/list', 'OrderController'); + $router->resource('slide/list', 'SlideController'); }); diff --git a/resources/lang/zh_CN/slide.php b/resources/lang/zh_CN/slide.php new file mode 100644 index 0000000..9c00674 --- /dev/null +++ b/resources/lang/zh_CN/slide.php @@ -0,0 +1,16 @@ + [ + 'Slide' => '轮播图', + 'slide' => '轮播图', + ], + 'fields' => [ + 'title' => '图片说明', + 'url' => '图片地址', + 'status' => '状态', + 'agent_id' => '代理商ID', + 'sort' => '排序', + ], + 'options' => [ + ], +];