column('id')->sortable(); $grid->column('product_type_id')->display(function (){ $lang = request()->session()->get('admin.config.lang'); if ($lang == 'ko'){ $data = ProductType::query()->whereIn('id',$this->product_type_id)->pluck('ko_name')->toArray(); }else{ $data = ProductType::query()->whereIn('id',$this->product_type_id)->pluck('zh_name')->toArray(); } return $data; })->label(); $grid->column('zh_name'); $grid->column('ko_name'); $grid->column('sort'); $grid->column('status')->switch(); $grid->column('created_at'); $grid->column('updated_at')->sortable(); $grid->filter(function (Grid\Filter $filter) { $filter->equal('id'); }); }); } /** * Make a show builder. * * @param mixed $id * * @return Show */ protected function detail($id) { return Show::make($id, new Column(), function (Show $show) { $show->field('id'); $show->field('product_type_id'); $show->field('zh_name'); $show->field('ko_name'); $show->field('sort'); $show->field('status'); $show->field('created_at'); $show->field('updated_at'); }); } /** * Make a form builder. * * @return Form */ protected function form() { return Form::make(new Column(), function (Form $form) { $form->display('id')->width(4); $form->multipleSelect('product_type_id')->options(ProductType::selectOptions())->required(); $form->text('zh_name')->required()->width(4); $form->text('ko_name')->required()->width(4); $form->number('sort')->width(4); $form->switch('status')->default(1); $form->display('created_at'); $form->display('updated_at'); }); } }