diff --git a/app/Admin/Controllers/TypeCorrelation.php b/app/Admin/Controllers/TypeCorrelation.php deleted file mode 100644 index 088b0fe..0000000 --- a/app/Admin/Controllers/TypeCorrelation.php +++ /dev/null @@ -1,80 +0,0 @@ -id->sortable(); - $grid->cover_img->image('',50); - $grid->type_name; - $grid->sort->sortable(); - // 排序 - $grid->model()->orderBy('id', 'desc'); - - $grid->filter(function (Grid\Filter $filter) { - $filter->like('type_name'); - }); - - // 每页10条 - $grid->paginate(10); - }); - } - - /** - * Make a show builder. - * - * @param mixed $id - * - * @return Show - */ - protected function detail($id) - { - // $s = StoreTypeModel::find(23); - // dd($s->cover_img_url); - return Show::make($id, new StoreType(), function (Show $show) { - $show->type_name->width(4); - $show->cover_img_url->image()->width(1); - $show->sort->width(1); - $show->created_at_text->width(2); - $show->updated_at_text->width(2); - }); - } - - /** - * Make a form builder. - * - * @return Form - */ - protected function form() - { - return Form::make(new StoreType(), function (Form $form) { - $form->hidden('id'); - $form->text('type_name')->required()->maxLength(20,'最多只能输入20个中文字'); - - /* uniqueName图片名称唯一,否则可能图片上传失败 */ - $form->image('cover_img')->required()->uniqueName(); - - $form->number('sort')->width(100); - - $form->disableResetButton(); - $form->disableViewCheck(); - $form->disableEditingCheck(); - $form->disableCreatingCheck(); - }); - } -} diff --git a/app/Admin/Controllers/TypeCorrelationController.php b/app/Admin/Controllers/TypeCorrelationController.php new file mode 100644 index 0000000..5d6aaab --- /dev/null +++ b/app/Admin/Controllers/TypeCorrelationController.php @@ -0,0 +1,117 @@ +id->sortable(); + $grid->store_type_name; + $grid->goods_type_id; + + $grid->filter(function (Grid\Filter $filter) { + $filter->equal('id'); + }); + + $grid->disableCreateButton(); + $grid->disableViewButton(); + $grid->disableEditButton(); + $grid->disableDeleteButton(); + $grid->disableBatchDelete(); + $grid->actions(function (Grid\Displayers\Actions $actions) { + // new TypeCorrelationBind() + $id = $actions->getKey(); + $actions->append('绑定'); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new TypeCorrelation(), function (Show $show) { + $show->id; + $show->store_type_id; + $show->goods_type_id; + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new TypeCorrelation(), function (Form $form) { + $form->hidden('id'); + + if ($form->isEditing()) { + + } + $storeName = $this->createNames(); + $form->listbox('goods_ids', '商品分类')->options($storeName); + + $form->disableHeader(); + $form->disableResetButton(); + $form->disableViewCheck(); + $form->disableEditingCheck(); + $form->disableCreatingCheck(); + }); + } + + /** + * 搜索获取店铺名称 + */ + protected function searchStoreName() + { + if (isset($this->storeName)) { + return $this->storeName; + } + $this->storeName = []; + $store = StoreModel::select('id','name')->where('name','like','')->get(); + + + return $this->storeName; + } + /** + * 生成随机数据 + * + * @return array + */ + protected function createNames() + { + if (isset($this->names)) { + return $this->names; + } + // $faker = Factory::create(); + $faker = ['胜多负少','sdsf','风格恢复']; + $this->names = []; + foreach ($faker as $key => $value) { + $name = $value; + $this->names[$name] = $name; + } + return $this->names; + } +} diff --git a/app/Admin/Extensions/TypeCorrelationBind.php b/app/Admin/Extensions/TypeCorrelationBind.php new file mode 100644 index 0000000..d1f1fb5 --- /dev/null +++ b/app/Admin/Extensions/TypeCorrelationBind.php @@ -0,0 +1,34 @@ +setHtmlAttribute(['class' => 'coupon-edit-row']); + return parent::html(); + } + +} diff --git a/app/Admin/Repositories/TypeCorrelation.php b/app/Admin/Repositories/TypeCorrelation.php new file mode 100644 index 0000000..597db80 --- /dev/null +++ b/app/Admin/Repositories/TypeCorrelation.php @@ -0,0 +1,16 @@ +resource('/storeType', 'StoreTypeController'); $router->resource('/goodsType', 'GoodsTypeController'); - + $router->resource('/typeCorrelation', 'TypeCorrelationController'); }); diff --git a/app/Models/LanzuStore.php b/app/Models/LanzuStore.php index 43a0aaf..7175f75 100644 --- a/app/Models/LanzuStore.php +++ b/app/Models/LanzuStore.php @@ -9,6 +9,16 @@ use Illuminate\Database\Eloquent\Model; class LanzuStore extends Model { use HasDateTimeFormatter; - protected $table = 'ims_cjdc_store'; + protected $table = 'lanzu_store'; protected $dateFormat = 'U'; + + public $timestamps = false; + + public function market(){ + return $this->hasOne('\App\Models\ImsCjdcMarket','id','market_id'); + } + + public function storeAccount(){ + return $this->hasMany(StoreAccount::class,'store_id','id'); + } } diff --git a/app/Models/TypeCorrelation.php b/app/Models/TypeCorrelation.php new file mode 100644 index 0000000..f114117 --- /dev/null +++ b/app/Models/TypeCorrelation.php @@ -0,0 +1,30 @@ +getStoreInfo($this->store_type_id,'name'); + + return $store ? $store->name : ''; + } + + public function getStoreInfo($id,$field = '*') + { + return LanzuStore::select($field)->find($id); + } +} diff --git a/database/migrations/2020_08_31_180258_create_lanzu_type_correlation_table.php b/database/migrations/2020_08_31_180258_create_lanzu_type_correlation_table.php new file mode 100644 index 0000000..4e414a2 --- /dev/null +++ b/database/migrations/2020_08_31_180258_create_lanzu_type_correlation_table.php @@ -0,0 +1,32 @@ +increments('id'); + $table->integer('store_type_id')->default('0')->nullable()->comment('一级分类(店铺分类)'); + $table->integer('goods_type_id')->default('0')->nullable()->comment('二级分类(商品分类)'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('lanzu_type_correlation'); + } +} diff --git a/resources/lang/zh-CN/type-correlation.php b/resources/lang/zh-CN/type-correlation.php new file mode 100644 index 0000000..e252f8c --- /dev/null +++ b/resources/lang/zh-CN/type-correlation.php @@ -0,0 +1,17 @@ + [ + 'TypeCorrelation' => '分类绑定', + 'typeCorrelation' => '分类绑定', + 'Edit' => '绑定', + 'edit' => '绑定' + ], + 'fields' => [ + 'store_type_id' => '一级分类(店铺)', + 'store_type_name' => '一级分类(店铺)', + 'goods_type_id' => '二级分类(商品)', + 'goods_type_name' => '二级分类(商品)', + ], + 'options' => [ + ], +];