api goods
parent
2d40e77720
commit
dda5a1b65e
|
|
@ -42,6 +42,8 @@ $menus = [
|
|||
|
||||
## API接口
|
||||
|
||||
- [在线预览](https://www.apifox.cn/apidoc/shared-86eb60cb-ba8f-46c6-b718-f33f99de5e7d)
|
||||
|
||||
## 数据表
|
||||
|
||||
### 商品分类: goods_category
|
||||
|
|
|
|||
|
|
@ -44,5 +44,6 @@ return [
|
|||
'created_at' => '创建时间',
|
||||
'updated_at' => '更新时间',
|
||||
'is_recommend' => '推荐',
|
||||
'description' => '描述',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ class GoodsController extends AdminController
|
|||
$info = Goods::with(['category', 'brand', 'type'])->findOrFail($id);
|
||||
$show = Show::make($info);
|
||||
$show->field('name');
|
||||
$show->field('description');
|
||||
$show->field('category_id')->as(function () {
|
||||
if (!$this->category) {
|
||||
return $this->category_id;
|
||||
|
|
@ -236,6 +237,7 @@ class GoodsController extends AdminController
|
|||
$form->select('category_id')->options(GoodsCategory::selectOptions(null, false))->required();
|
||||
$form->select('brand_id')->options(GoodsBrand::pluck('name', 'id'));
|
||||
$form->text('name')->required();
|
||||
$form->text('description');
|
||||
$form->text('goods_sn')->rules([$unique], [
|
||||
'unique' => '商品编号已经存在',
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class GoodsController extends Controller
|
|||
|
||||
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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,10 @@ class GoodsResource extends GoodsTinyResource
|
|||
|
||||
return array_merge($data, [
|
||||
'content' => $this->content,
|
||||
'weight' => $this->weight,
|
||||
'volume' => $this->volume,
|
||||
'shipping_tmp_id' => $this->shipping_tmp_id,
|
||||
'attr' => $this->attr,
|
||||
'part' => $this->part,
|
||||
'spec' => $this->spec,
|
||||
'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')),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -14,12 +14,8 @@ class GoodsSkuResource extends JsonResource
|
|||
'goods_id' => $this->goods_id,
|
||||
'name' => $this->name,
|
||||
'price' => $this->price,
|
||||
'vip_price' => $this->vip_price,
|
||||
'stock' => $this->stock,
|
||||
'spec' => $this->spec,
|
||||
'weight' => $this->weight,
|
||||
'volume' => $this->volume,
|
||||
'shipping_tmp_id' => $this->shipping_tmp_id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace Peidikeji\Goods\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Peidikeji\Merchant\Http\Resources\MerchantTinyResource;
|
||||
|
||||
class GoodsTinyResource extends JsonResource
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue