4
0
Fork 0

api goods

master
panliang 2022-09-13 14:52:56 +08:00
parent 2d40e77720
commit dda5a1b65e
7 changed files with 6 additions and 14 deletions

View File

@ -42,6 +42,8 @@ $menus = [
## API接口 ## API接口
- [在线预览](https://www.apifox.cn/apidoc/shared-86eb60cb-ba8f-46c6-b718-f33f99de5e7d)
## 数据表 ## 数据表
### 商品分类: goods_category ### 商品分类: goods_category

View File

@ -44,5 +44,6 @@ return [
'created_at' => '创建时间', 'created_at' => '创建时间',
'updated_at' => '更新时间', 'updated_at' => '更新时间',
'is_recommend' => '推荐', 'is_recommend' => '推荐',
'description' => '描述',
], ],
]; ];

View File

@ -176,6 +176,7 @@ class GoodsController extends AdminController
$info = Goods::with(['category', 'brand', 'type'])->findOrFail($id); $info = Goods::with(['category', 'brand', 'type'])->findOrFail($id);
$show = Show::make($info); $show = Show::make($info);
$show->field('name'); $show->field('name');
$show->field('description');
$show->field('category_id')->as(function () { $show->field('category_id')->as(function () {
if (!$this->category) { if (!$this->category) {
return $this->category_id; return $this->category_id;
@ -236,6 +237,7 @@ class GoodsController extends AdminController
$form->select('category_id')->options(GoodsCategory::selectOptions(null, false))->required(); $form->select('category_id')->options(GoodsCategory::selectOptions(null, false))->required();
$form->select('brand_id')->options(GoodsBrand::pluck('name', 'id')); $form->select('brand_id')->options(GoodsBrand::pluck('name', 'id'));
$form->text('name')->required(); $form->text('name')->required();
$form->text('description');
$form->text('goods_sn')->rules([$unique], [ $form->text('goods_sn')->rules([$unique], [
'unique' => '商品编号已经存在', 'unique' => '商品编号已经存在',
]); ]);

View File

@ -22,7 +22,7 @@ class GoodsController extends Controller
public function show($id) public function show($id)
{ {
$info = Goods::with(['merchant', 'skus'])->show()->findOrFail($id); $info = Goods::with(['skus'])->show()->findOrFail($id);
return $this->json(GoodsResource::make($info)); return $this->json(GoodsResource::make($info));
} }

View File

@ -10,18 +10,10 @@ class GoodsResource extends GoodsTinyResource
return array_merge($data, [ return array_merge($data, [
'content' => $this->content, 'content' => $this->content,
'weight' => $this->weight,
'volume' => $this->volume,
'shipping_tmp_id' => $this->shipping_tmp_id,
'attr' => $this->attr, 'attr' => $this->attr,
'part' => $this->part, 'part' => $this->part,
'spec' => $this->spec, 'spec' => $this->spec,
'created_at' => $this->created_at->timestamp, 'created_at' => $this->created_at->timestamp,
'check_user_id' => $this->check_user_id,
'check_at' => $this->check_at?->timestamp,
'check_remarks' => $this->check_remarks,
'check_status' => $this->check_status,
'check_status_text' => $this->check_status->text(),
'skus' => GoodsSkuResource::collection($this->whenLoaded('skus')), 'skus' => GoodsSkuResource::collection($this->whenLoaded('skus')),
]); ]);

View File

@ -14,12 +14,8 @@ class GoodsSkuResource extends JsonResource
'goods_id' => $this->goods_id, 'goods_id' => $this->goods_id,
'name' => $this->name, 'name' => $this->name,
'price' => $this->price, 'price' => $this->price,
'vip_price' => $this->vip_price,
'stock' => $this->stock, 'stock' => $this->stock,
'spec' => $this->spec, 'spec' => $this->spec,
'weight' => $this->weight,
'volume' => $this->volume,
'shipping_tmp_id' => $this->shipping_tmp_id,
]; ];
} }
} }

View File

@ -3,7 +3,6 @@
namespace Peidikeji\Goods\Http\Resources; namespace Peidikeji\Goods\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
use Peidikeji\Merchant\Http\Resources\MerchantTinyResource;
class GoodsTinyResource extends JsonResource class GoodsTinyResource extends JsonResource
{ {