'require', 'name' => 'require|length:1,50', 'phone' => 'require|mobile', 'id_card' => 'length:15,18', 'age' => 'number|between:0,150', 'gender' => 'in:0,1,2', 'status' => 'in:0,1', ]; protected $message = [ 'id.require' => '参数缺失', 'name.require' => '请输入姓名', 'name.length' => '姓名长度须在1-50位字符', 'phone.require' => '请输入手机号', 'phone.mobile' => '手机号格式不正确', 'id_card.length' => '身份证号长度不正确', 'age.number' => '年龄必须为数字', 'age.between' => '年龄范围0-150', 'gender.in' => '性别参数错误', 'status.in' => '状态参数错误', ]; public function sceneAdd() { return $this->remove('id', true); } public function sceneEdit() { return $this->only(['id', 'name', 'phone', 'id_card', 'age', 'gender', 'status']); } public function sceneId() { return $this->only(['id']); } }