ScoreClockinActive.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php namespace App\Http\Requests\Company;
  2. use App\Http\Requests\BaseRequest;
  3. use Illuminate\Validation\Rule;
  4. /**
  5. * 积分打卡验证器
  6. *
  7. */
  8. class ScoreClockinActive extends BaseRequest
  9. {
  10. /**
  11. * 获取应用于请求的规则
  12. *
  13. * @return array
  14. */
  15. public function rules()
  16. {
  17. // 编辑时排除ID
  18. $id = request('id',0);
  19. // 返回结果
  20. return [
  21. // 有时候我们希望某个字段在第一次验证失败后就停止运行验证规则,只需要将 bail 添加到规则中:
  22. // 验证字段,验证规则,提示信息
  23. 'name' => ['required'],
  24. 'id' => 'required|integer|gt:0',
  25. ];
  26. }
  27. // 场景列表
  28. protected $scenes = [
  29. 'add' => ['name'],
  30. 'edit' => ['id','name'],
  31. 'set_status' => ['id'],
  32. 'copy' => ['id'],
  33. ];
  34. /**
  35. * 获取已定义验证规则的错误消息
  36. *
  37. * @return array
  38. */
  39. public function messages()
  40. {
  41. return [
  42. 'name.required' => '活动名称必填',
  43. 'id.required' => 'ID未知',
  44. 'id.integer' => 'ID格式错误',
  45. 'id.gt' => 'ID格式错误',
  46. ];
  47. }
  48. }
  49. ?>