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->editForm($id)->edit($id)); } /** * Create interface. * * @param Content $content * @return Content */ public function create(Content $content) { return $content ->header('导航分类') ->description('创建') ->body($this->createForm()); } /** * Make a grid builder. * * @return Grid */ protected function grid() { $grid = new Grid(new NavigationCategory); $grid->id('ID'); $grid->alias('分类别名')->width(150); $grid->name('分类名称')->width(150); $grid->admin_set('类别')->display(function ($admin_set) { return $admin_set ? '系统内置' : '自定义'; }); $grid->created_at('添加时间'); $grid->updated_at('更新时间'); $grid->actions(function ($actions) use ($grid) { if (Admin::user()->can('system_nav_type_edit')) { $actions->disableEdit(false); } if (Admin::user()->can('system_nav_type_delete')) { $actions->disableDelete(false); } }); if (Admin::user()->can('system_nav_type_delete')) { $grid->tools(function ($tools) { $tools->batch(function ($batch) { $batch->disableDelete(false); }); }); $grid->disableRowSelector(false); } if (Admin::user()->can('system_nav_type_create')) { $grid->disableCreateButton(false); } return $grid; } /** * Make a show builder. * * @param mixed $id * @return Show */ protected function detail($id) { $show = new Show(NavigationCategory::findOrFail($id)); $show->id('ID'); $show->alias('分类别名'); $show->name('分类名称'); $show->admin_set('类别')->as(function ($admin_set) { return $admin_set ? '系统内置' : '自定义'; }); $show->created_at('添加时间'); $show->updated_at('更新时间'); return $show; } /** * Make a form builder. * * @return Form */ protected function editForm($id) { $form = new Form(new NavigationCategory); $form->text('alias', '分类别名')->rules([ 'required', Rule::unique('navigation_categorys')->ignore($id), ])->setWidth(3)->setMustMark(); $form->text('name', '分类名称')->rules([ 'required', Rule::unique('navigation_categorys')->ignore($id), ])->setWidth(3)->setMustMark(); $form->radio('admin_set', '类别')->options(['1'=>'系统内置',0=>'自定义']); return $form; } protected function createForm() { $form = new Form(new NavigationCategory); $form->text('alias', '分类别名')->rules([ 'required', 'unique:navigation_categorys', ])->setWidth(3)->setMustMark(); $form->text('name', '分类名称')->rules([ 'required', 'unique:navigation_categorys', ])->setWidth(3)->setMustMark(); $form->radio('admin_set', '类别')->options(['1'=>'系统内置',0=>'自定义']); return $form; } /** * Store a newly created resource in storage. * * @return mixed */ public function store() { return $this->createForm()->store(); } /** * Update the specified resource in storage. * * @param int $id * * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response */ public function update($id) { return $this->editForm($id)->update($id); } protected function form() { $form = new Form(new NavigationCategory); $form->display('ID'); $form->display('添加时间'); $form->display('更新时间'); return $form; } }