PhOrders.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class PhOrders extends Validate{
  6. /**
  7. * 定义验证规则
  8. * 格式:'字段名' => ['规则1','规则2'...]
  9. *
  10. * @var array
  11. */
  12. protected $rule = [
  13. 'contact|联系人' => 'require',
  14. 'phone|联系手机号' => 'require|checkPhone',
  15. 'dep_id|科室' => 'require|gt:0',
  16. 'id' => "require|gt:0",
  17. 'name|姓名' => 'require',
  18. 'age|年龄' => 'require|gt:0',
  19. 'bed|床号' => 'require',
  20. 'ill|所患疾病' => 'require',
  21. 'start|预约时间' => 'require',
  22. 'cate_id|服务' => 'require|gt:0',
  23. 'price|价格' => 'require|gt:0',
  24. ];
  25. /**
  26. * 定义错误信息
  27. * 格式:'字段名.规则名' => '错误信息'
  28. *
  29. * @var array
  30. */
  31. protected $message = [
  32. 'id.require' => '参数错误',
  33. 'id.gt' => '参数错误',
  34. 'dep_id.require' => '未选择科室',
  35. 'dep_id.gt' => '未选择科室',
  36. 'cate_id.require' => '未选择服务',
  37. 'cate_id.gt' => '未选择服务'
  38. ];
  39. protected $scene = [
  40. 'add' => ['contact','phone','start','dep_id','cate_id'],
  41. 'edit' => ['id','contact','phone'],
  42. 'book' => ['contact','phone','name','age','bed','ill','start','cate_id'],
  43. 'qadd' => ['contact','phone','name','age','bed','ill','start','cate_id','price']
  44. ];
  45. protected function checkPhone($value, $rule, $data=[]){
  46. if(!check_mobile($value)){
  47. return '手机号格式错误';
  48. }
  49. return true;
  50. }
  51. }