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

批量上架or下架商品


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

php
// 上架/下架
   public function changeStatus(){
   	$params = request()->param();
   	$res = $this->M->where('id','in',$params['ids'])->update([
   		'status'=>$params['status']
   	]);
   	return showSuccess($res);
   }

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

// 验证规则
protected $rule = [
    ...
    'ids'=>'require|array',
	'status'=>'require|in:0,1',
    ...
];

protected $scene = [
    // ...
    'changeStatus'=>['ids','status'],
];

路由 router/admin.php

Route::post('goods/changestatus','admin.goods/changeStatus');