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

修改商品类型状态


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

php
public function updateStatus()
{
    $rule = $this->request->Model;
    $rule->status = $this->request->param('status');
    return showSuccess($rule->save());
}

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

php
// 验证规则
protected $rule = [
    ...
    'id'=>'require|integer|>:0|isExist:GoodsType',
    'status'=>'require|integer|in:0,1'
    ...
];
protected $scene = [
    ...
    'updateStatus'=>['id','status'],
];

路由 router/admin.php

php
Route::post('goods_type/:id/update_status','admin.GoodsType/updateStatus');