model()->orderByDesc('sort'); $grid->column('id')->sortable(); $grid->column('name')->label('info'); $grid->column('cate_id')->display(function (){ return $this->cate->name; })->label('success'); $grid->column('cover_img')->image('',80); $grid->column('cases')->display(function (){ $html = ''; foreach ($this->cases as $case){ $html .= ''; } return $html; }); $grid->column('tech_param')->display(function (){ $html = ''; foreach ($this->tech_param as $key => $tech_param){ $index = $key+1; $html .= "参数文件{$index}
"; } return $html; }); $grid->column('cad_model')->display(function (){ $html = ''; foreach ($this->cad_model as $key => $tech_param){ $index = $key+1; $html .= "CAD模型{$index}
"; } return $html; }); $grid->column('cad_design')->display(function (){ $html = ''; foreach ($this->cad_design as $key => $tech_param){ $index = $key+1; $html .= "CAD设计$index
"; } return $html; }); $grid->column('su_model')->display(function (){ $html = ''; foreach ($this->su_model as $key => $tech_param){ $index = $key+1; $html .= "SU模型{$index}
"; } return $html; }); $grid->column('other')->display(function (){ $html = ''; foreach ($this->other as $key => $tech_param){ $index = $key+1; $html .= "其他文件{$index}
"; } return $html; }); $grid->column('is_opened')->switch(); $grid->column('sort')->editable(); $grid->column('created_at'); $grid->actions(function (Grid\Displayers\Actions $actions) { $id = $actions->getKey(); // append一个操作 $actions->append(' 规格管理'); }); $grid->filter(function (Grid\Filter $filter) { $filter->panel(); $filter->like('name')->width(2); }); $grid->disableViewButton(); }); } /** * Make a show builder. * * @param mixed $id * * @return Show */ protected function detail($id) { return Show::make($id, new Product(), function (Show $show) { $show->field('id'); $show->field('name'); $show->field('cover_img'); $show->field('cases'); $show->field('origin_price'); $show->field('sale_price'); $show->field('sort'); $show->field('is_opened'); $show->field('tech_param'); $show->field('cad_model'); $show->field('cad_design'); $show->field('su_model'); $show->field('other'); $show->field('created_at'); $show->field('updated_at'); }); } /** * Make a form builder. * * @return Form */ protected function form() { return Form::make(new Product(), function (Form $form) { $form->display('id'); $cates = ProductCategory::select(['id','name'])->where('is_opened',1)->get()->toArray(); $form->select('cate_id') ->options(array_column($cates,'name','id')) ->required();; $form->text('name')->required();;; $form->image('cover_img')->saveFullUrl() ->uniqueName()->autoUpload() ->autoSave(false) ->removable(false) ->width(4) ->required(); $form->multipleImage('cases')->saveFullUrl() ->uniqueName()->autoUpload() ->autoSave(false) ->removable(false) ->width(4); $form->multipleFile('tech_param')->saveFullUrl() ->uniqueName()->autoUpload() ->autoSave(false) ->removable(false) ->width(4); $form->multipleFile('cad_model')->saveFullUrl() ->uniqueName()->autoUpload() ->autoSave(false) ->removable(false) ->width(4); $form->multipleFile('cad_design')->saveFullUrl() ->uniqueName()->autoUpload() ->autoSave(false) ->removable(false) ->width(4); $form->multipleFile('su_model')->saveFullUrl() ->uniqueName()->autoUpload() ->autoSave(false) ->removable(false) ->width(4); $form->multipleFile('other')->saveFullUrl() ->uniqueName()->autoUpload() ->autoSave(false) ->removable(false) ->width(4); $form->radio('is_opened')->options(config('global.bool_status'))->default(1); $form->number('sort'); $form->disableViewButton(); $form->disableDeleteButton(); $form->disableListButton(); $form->disableEditingCheck(); $form->disableViewCheck(); $form->disableCreatingCheck(); }); } }