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

修改商品规格状态


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

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

验证器 app/validate/admin/Skus.php // 验证规则

php
protected $rule = [
    ...
    'id'=>'require|integer|>:0|isExist:Skus',
    'status'=>'require|integer|in:0,1'
    ...
];

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

路由 router/admin.php

php
Route::post('skus/:id/update_status','admin.Skus/updateStatus');