Skip to content
关注公众号,获取新课通知

查看商品资料


控制器 app/controller/admin/Goods.php

php
// 后端商品详情
public function adminread($id)
   {
   	$goods = request()->Model->append(['goodsBanner','goodsAttrs','goodsSkus','goodsSkusCard.goodsSkusCardValue']);
   	// 商品类型列表
       $types = (new \app\model\GoodsType())->with(['goodsTypeValues'=>function($q){
       	$q->where('status',1);
       }])->where('status',1)->select();
       
       $goods->types = $types;
       return showSuccess($goods);
   }

验证器 app/validate/admin/Goods.php

php
// 验证规则
protected $rule = [
    ...
    'id'=>'require|integer|>:0|isExist:Goods',
    ...
];

protected $scene = [
    ...
    'adminread'=>['id'],
];

路由 router/admin.php

php
Route::get('goods/read/:id','admin.Goods/adminread');