| xqd
@@ -20,9 +20,13 @@ class ProductController extends AdminController
|
|
|
protected function grid()
|
|
|
{
|
|
|
return Grid::make(new Product(), function (Grid $grid) {
|
|
|
- $grid->model()->with(['type:id,zh_name,ko_name','user:id,name'])->orderByDesc('id');
|
|
|
+ $grid->model()->orderByDesc('id');
|
|
|
$grid->column('id')->sortable();
|
|
|
$grid->column('image')->image('',40);
|
|
|
+ $grid->column('type')->display(function (){
|
|
|
+ $arr = \App\Models\ProductType::query()->whereIn('id',$this->type)->pluck('zh_name');
|
|
|
+ return $arr;
|
|
|
+ })->label();
|
|
|
$grid->column('type.zh_name',admin_trans_field('type'));
|
|
|
$grid->column('user.name',admin_trans_field('user_id'));
|
|
|
$grid->column('name');
|
| xqd
@@ -70,7 +74,15 @@ class ProductController extends AdminController
|
|
|
{
|
|
|
return Form::make(new Product(), function (Form $form) {
|
|
|
$form->display('id')->width(4);
|
|
|
- $form->select('type')->options(\App\Models\ProductType::selectOptions())->required()->width(4);
|
|
|
+
|
|
|
+ $form->multipleSelect('type')
|
|
|
+ ->options(\App\Models\ProductType::selectOptions())
|
|
|
+ ->saving(function ($value) {
|
|
|
+ // 转化成json字符串保存到数据库
|
|
|
+ return json_encode($value);
|
|
|
+ });
|
|
|
+
|
|
|
+// $form->select('type')->options(\App\Models\ProductType::selectOptions())->required()->width(4);
|
|
|
$form->select('user_id')->width(4)->options(User::query()->where('status',1)->pluck('name','id'))->required();
|
|
|
$form->text('name')->required()->width(4);
|
|
|
$form->textarea('content')->required()->width(4);
|