header('轮播图管理')
->description('列表')
->body($this->grid());
}
/**
* Show interface.
*
* @param mixed $id
* @param Content $content
* @return Content
*/
public function show($id, Content $content)
{
return $content
->header('轮播图管理')
->description('详情')
->body($this->detail($id));
}
/**
* Edit interface.
*
* @param mixed $id
* @param Content $content
* @return Content
*/
public function edit($id, Content $content)
{
return $content
->header('轮播图管理')
->description('编辑')
->body($this->form()->edit($id));
}
/**
* Create interface.
*
* @param Content $content
* @return Content
*/
public function create(Content $content)
{
return $content
->header('轮播图管理')
->description('创建')
->body($this->form());
}
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$grid = new Grid(new Lunbo);
$grid->id('编号');
$grid->name('名称');
$grid->link('链接');
$grid->img('图像')->display(function ($img) {
return '
';
});;
$grid->isshow('是否显示')->display(function ($value) {
return $value ? '是' : '否';
});
$grid->created_at('创建时间');
$grid->updated_at('更新时间');
$grid->disableExport();
$grid->disableFilter();
$grid->actions(function (Grid\Displayers\Actions $actions) {
$actions->disableView();
});
return $grid;
}
/**
* Make a show builder.
*
* @param mixed $id
* @return Show
*/
protected function detail($id)
{
$show = new Show(Lunbo::findOrFail($id));
$show->id('编号');
$show->name('名字');
$show->img('图片')->unescape()->as(function () {
return '
';
});
$show->isshow('是否显示')->as(function () {
return $this->isshow ? '是' : '否';
});
$show->created_at('创建时间');
$show->updated_at('更新时间');
return $show;
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
$form = new Form(new Lunbo);
$form->text('name', '名称')->rules('required');
$form->image('img', '图片')->uniqueName()->rules('required')->help('建议比例为25:7');
$form->switch('isshow', '是否显示');
$form->url('link', '链接');
$form->tools(function (Form\Tools $tools) {
$tools->disableView();
});
return $form;
}
}