diff --git a/database/seeders/GoodsCategorySeeder.php b/database/seeders/GoodsCategorySeeder.php index 7707226..ee5714b 100644 --- a/database/seeders/GoodsCategorySeeder.php +++ b/database/seeders/GoodsCategorySeeder.php @@ -71,18 +71,15 @@ class GoodsCategorySeeder extends Seeder ]], ]], ]; - + foreach ($categoryList as $index => $item) { $attributes = Arr::except($item, ['children']); $category = GoodsCategory::create(array_merge([ 'parent_id' => 0, 'sort' => $index + 1, ], $attributes)); - } - - foreach ($categoryList as $index => $item) { if ($children = data_get($item, 'children')) { - $this->createCategory($children, $item['id'] ?? 0); + $this->createCategory($children, $category->id); } } } diff --git a/src/Form/Check/HandleCheckForm.php b/src/Form/Check/HandleCheckForm.php deleted file mode 100644 index 7c81cff..0000000 --- a/src/Form/Check/HandleCheckForm.php +++ /dev/null @@ -1,38 +0,0 @@ -payload['id']); - try { - DB::beginTransaction(); - GoodsService::make()->handleCheck($info, Admin::user(), (bool) $input['check_status'], $input['check_remarks']); - DB::commit(); - - return $this->response()->success('操作成功')->refresh(); - } catch (\Exception $e) { - DB::rollBack(); - - return $this->response()->error($e->getMessage()); - } - } - - public function form() - { - $this->radio('check_status')->options([1 => '通过', 0 => '不通过'])->default(1); - $this->textarea('check_remarks'); - } -} diff --git a/src/GoodsServiceProvider.php b/src/GoodsServiceProvider.php index a43405b..b043f73 100644 --- a/src/GoodsServiceProvider.php +++ b/src/GoodsServiceProvider.php @@ -6,6 +6,11 @@ use Illuminate\Support\ServiceProvider; class GoodsServiceProvider extends ServiceProvider { + protected $menu = [ + ['title' => '商品模块', 'icon' => 'feather icon-layers', 'uri' => ''], + ['parent' => '商品模块', 'title' => '商品分类', 'icon' => '', 'uri' => '/goods-category'], + ]; + public function register() { } diff --git a/src/Http/Admin/GoodsCategoryController.php b/src/Http/Admin/GoodsCategoryController.php index 84b1cc5..e7f0f73 100644 --- a/src/Http/Admin/GoodsCategoryController.php +++ b/src/Http/Admin/GoodsCategoryController.php @@ -18,7 +18,7 @@ class GoodsCategoryController extends AdminController $grid->disableRowSelector(); - $grid->column('name')->tree(true, false); + $grid->column('name')->tree(); $grid->column('image')->image('', 100); $grid->column('sort')->editable(['mask' => '{alias:\'numeric\',min:0,max:999}']); $grid->column('is_enable')->switch(); diff --git a/src/Http/Admin/GoodsCheckController.php b/src/Http/Admin/GoodsCheckController.php deleted file mode 100644 index 9d9d777..0000000 --- a/src/Http/Admin/GoodsCheckController.php +++ /dev/null @@ -1,75 +0,0 @@ -model()->sort(); - - $grid->column('merchant.name'); - $grid->column('category.name'); - $grid->column('name')->display(function () { - return ($this->cover_image ? ' ' : '').''.$this->name.''; - }); - $grid->column('price'); - $grid->column('vip_price'); - $grid->column('check_status')->display(fn () => $this->check_status->dot()); - $grid->column('created_at', '申请时间'); - - $grid->showViewButton(); - $grid->actions(function (Actions $actions) { - $row = $actions->row; - if ($row->check_status === CheckStatus::Processing) { - $actions->append(new RowHandleCheck()); - } - }); - }); - } - - protected function detail($id) - { - Admin::css([ - 'vendor/dcat-admin-goods/goods.css', - ]); - $info = GoodsCheck::with(['category', 'brand', 'type'])->findOrFail($id); - $show = Show::make($info); - $show->field('goods_sn'); - $show->field('category.name'); - $show->field('brand.name'); - $show->field('type.name'); - $show->field('name'); - $show->field('price'); - $show->field('vip_price'); - $show->field('score_discount_amount'); - $show->field('cover_image')->image('', 100); - $show->field('images')->image('', 100); - $show->field('content')->image(''); - $show->field('spec')->view('dcat-admin-goods::goods.grid-attr'); - $show->field('attr')->view('dcat-admin-goods::goods.grid-attr'); - $show->field('part')->view('dcat-admin-goods::goods.grid-attr'); - $show->field('on_sale')->bool(); - $show->field('sold_count'); - $show->field('check_status')->unescape()->as(fn () => $this->check_status->label()); - $show->field('check_at'); - $show->field('check_remarks'); - $show->field('check_user.name'); - $show->field('created_at')->as(fn ($v) => $this->created_at->format('Y-m-d H:i:s')); - $show->field('updated_at')->as(fn ($v) => $this->updated_at->format('Y-m-d H:i:s')); - - return $show; - } -} diff --git a/src/Models/GoodsCategory.php b/src/Models/GoodsCategory.php index 3a2e198..131709f 100644 --- a/src/Models/GoodsCategory.php +++ b/src/Models/GoodsCategory.php @@ -53,20 +53,6 @@ class GoodsCategory extends Model }); } - public static function selectOptions(\Closure $closure = null, $rootText = null) - { - $options = (new static())->withQuery($closure)->buildSelectOptions(static::query()->where('path', 'like', '-1-%')->sort()->get()->toArray(), 1); - - $list = collect($options); - - if ($rootText !== false) { - $rootText = $rootText ?: admin_trans_label('root'); - $list->prepend($rootText, 0); - } - - return $list->all(); - } - public function modelFilter() { return GoodsCategoryFilter::class;