column('id','ID')->sortable(); $grid->column('title'); $grid->column('sku'); $grid->column('baseProductCategory.name','Category Name'); $grid->column('publish_date'); $grid->column('order')->orderable(); $grid->column('enabled')->switch(); $grid->column('created_at'); $grid->column('updated_at')->sortable(); // 筛选 $grid->filter(function (Grid\Filter $filter) { $filter->equal('sku'); $filter->like('title'); $filter->equal('category_id','Category')->select(BaseProductCategory::selectOptions()); }); //排序 $grid->model()->orderBy("order",'asc')->orderBy('id', 'desc'); // 禁用查看按钮 $grid->disableViewButton(); $grid->showQuickEditButton(); $grid->enableDialogCreate(); $grid->disableEditButton(); }); } /** * Make a show builder. * * @param mixed $id * * @return Show */ protected function detail($id) { return Show::make($id, new BaseProduct(), function (Show $show) { $show->field('id'); $show->field('title'); $show->field('keywords'); $show->field('description'); $show->field('sku'); $show->field('baseProductCategory.name','Category Name'); $show->field('publish_date'); $show->field('order'); $show->field('enabled'); $show->field('content'); $show->field('parameters'); $show->field('created_at'); $show->field('updated_at'); }); } /** * Make a form builder. * * @return Form */ protected function form() { return Form::make(new BaseProduct(), function (Form $form) { $form->display('id'); $form->text('title'); $form->text('keywords'); $form->text('description'); $form->text('sku'); $form->select('category_id', 'Category Name') ->options(BaseProductCategory::all()->pluck('name', 'id')) ->required(); $form->text('publish_date'); $form->text('order'); $form->text('enabled'); $form->text('content'); $form->text('parameters'); $form->display('created_at'); $form->display('updated_at'); }); } }