disableCreateButton(); // 禁用编辑功能 // $grid->disableActions(); $grid->column('id', __('ID'))->sortable(); $grid->column('name', __('名称')); $grid->column('is_show', __('是否显示')); // ->display(function ($isShow) { // return SpecialistCloumn::$isShowMap[$isShow]; // }); $grid->column('rank', __('排序(越大越靠前)'))->sortable(); $grid->column('created_at', __('创建时间')); $grid->column('updated_at', __('更新时间')); $grid->model()->where('pid', SpecialistCloumn::PID_0); // 新增过滤 $grid->filter(function ($filter) { $filter->like('name', '名称'); $filter->equal('is_show', '是否显示')->radio(SpecialistCloumn::$isShowMap); }); return $grid; } /** * Make a show builder. * * @param mixed $id * @return Show */ protected function detail($id) { $show = new Show(SpecialistCloumn::findOrFail($id)); $show->field('id', __('ID')); $show->field('created_at', __('Created at')); $show->field('updated_at', __('Updated at')); return $show; } /** * Make a form builder. * * @return Form */ protected function form() { $form = new Form(new SpecialistCloumn); $form->display('id', __('ID'))->rules('required'); $form->text('name', __('名称'))->rules('required'); $form->image('pic', __('图片'))->uniqueName()->move('pics/'.date('Y').'/'.date('m'))->rules('required'); $form->text('url', __('链接地址'))->rules('required'); $form->table('banner', function ($table) { $table->image('src', '广告图')->uniqueName()->move('pics/'.date('Y').'/'.date('m'))->rules('required'); $table->text('url', '链接地址')->rules('required'); }); $states = [ 'on' => ['value' => 1, 'text' => '显示', 'color' => 'success'], 'off' => ['value' => 0, 'text' => '不显示', 'color' => 'danger'], ]; $form->switch('is_show', __('是否显示'))->states($states); $form->number('rank', __('排序(越大越靠前)'))->default(0); return $form; } }