diff --git a/app/Admin/Controllers/HomeController.php b/app/Admin/Controllers/HomeController.php index a2c02577..d9e166fd 100644 --- a/app/Admin/Controllers/HomeController.php +++ b/app/Admin/Controllers/HomeController.php @@ -17,21 +17,22 @@ class HomeController extends Controller public function index(Content $content) { return $content - ->header('首页') - ->description('首页') - ->body(function (Row $row) { - $row->column(6, function (Column $column) { + ->header('首页') + ->description('首页') + ->body(function (Row $row) { + $user = Admin::user(); + $row->column(6, function (Column $column) use ($user) { $column->row(Dashboard::title()); - if (Admin::user()->can('dcat.admin.home.statistics')) { + if ($user->can('dcat.admin.home.statistics')) { $column->row(new StatisticsTotal()); } }); - $row->column(6, function (Column $column) { - if (Admin::user()->can('dcat.admin.home.new_users')) { + $row->column(6, function (Column $column) use ($user) { + if ($user->can('dcat.admin.home.new_users')) { $column->row(new NewUsers()); } - if (Admin::user()->can('dcat.admin.home.orders')) { + if ($user->can('dcat.admin.home.orders')) { $column->row(new Orders()); } }); diff --git a/app/Admin/Imports/StoreProduct.php b/app/Admin/Imports/StoreProduct.php index 4a12336f..dc4f4799 100644 --- a/app/Admin/Imports/StoreProduct.php +++ b/app/Admin/Imports/StoreProduct.php @@ -27,6 +27,7 @@ class StoreProduct $index = 0; $storeName = $cells[$index];// 店铺名称 $goodsName = $cells[++$index];// 商品名称 + $stock = $cells[++$index];// 库存 $goodsTitle = $cells[++$index];// 商品副标题 $categoryName = $cells[++$index];// 分类名称 $goodsImage = $cells[++$index];// 商品图片 @@ -47,65 +48,62 @@ class StoreProduct // https://qiniu.abcdefg.fun/banner/banner4.png,https://qiniu.abcdefg.fun/banner/banner5.png $goodsContent = $cells[++$index]; - $stock = $cells[++$index];// 库存 - $store = Store::where(['title' => $storeName])->first(); if (!$store) { throw new ImportException('门店 '.$storeName.' 不存在'); - } - - $goods = [ - 'name' => $goodsName, - 'subtitle' => $goodsTitle, - 'shipping_template_id' => 1, - ]; - $category = ProductCategory::where('name', $categoryName)->first(); - if (!$category) { - throw new ImportException('分类 '.$categoryName.' 不存在'); - } - $goods['category_id'] = $category->id; + } - // 图片组 - if ($goodsImage) { - if (Str::startsWith($goodsImage, ['http://', 'https://'])) { - $images = explode(',', $goodsImage); - } else { - $images = $this->getImageUrlFromPath($goodsImage); - } - if (count($images) > 0) { - $goods['cover'] = $images[0]; - $goods['images'] = $images; - } - } - - // 运费模板 - if ($shipTemplate) { - $goods['shipping_template_id'] = $shipTemplate; - } - // 重量 - if ($goodsWeight) { - $goods['weight'] = $goodsWeight; - } - // 详细描述 - if ($goodsContent) { - $description = ''; - foreach(explode(',', $goodsContent) as $item) { - $description .= '