['规则1','规则2'...] * * @var array */ protected $rule = [ 'contact|联系人' => 'require', 'phone|联系手机号' => 'require|checkPhone', 'dep_id|科室' => 'require|gt:0', 'id' => "require|gt:0", 'name|姓名' => 'require', 'age|年龄' => 'require|gt:0', 'bed|床号' => 'require', 'ill|所患疾病' => 'require', 'start|预约时间' => 'require', 'cate_id|服务' => 'require|gt:0', 'price|价格' => 'require|gt:0', ]; /** * 定义错误信息 * 格式:'字段名.规则名' => '错误信息' * * @var array */ protected $message = [ 'id.require' => '参数错误', 'id.gt' => '参数错误', 'dep_id.require' => '未选择科室', 'dep_id.gt' => '未选择科室', 'cate_id.require' => '未选择服务', 'cate_id.gt' => '未选择服务' ]; protected $scene = [ 'add' => ['contact','phone','start','dep_id','cate_id'], 'edit' => ['id','contact','phone'], 'book' => ['contact','phone','name','age','bed','ill','start','cate_id'], 'qadd' => ['contact','phone','name','age','bed','ill','start','cate_id','price'] ]; protected function checkPhone($value, $rule, $data=[]){ if(!check_mobile($value)){ return '手机号格式错误'; } return true; } }