AddChannelRequest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. *
  4. * @file:AddChannelRequest.php
  5. * @Date: 2023/6/8
  6. * @Time: 14:50
  7. */
  8. namespace Modules\Operation\Http\Requests;
  9. use Illuminate\Foundation\Http\FormRequest;
  10. use Modules\Operation\Service\ChannelServic;
  11. class AddChannelRequest extends FormRequest
  12. {
  13. public function rules(): array
  14. {
  15. return [
  16. 'status' => 'required|in:0,1',
  17. 'type' => [
  18. 'required',
  19. 'Integer',
  20. "gt:0",
  21. function ($attribute, $value, $fail) {
  22. $types = array_column(ChannelServic::getNavPagesType(),'value');
  23. if (!in_array($value,$types)) {
  24. $fail("频道类型不正确");
  25. }
  26. },
  27. ],
  28. 'miniprogram_type' => [
  29. 'required',
  30. 'Integer',
  31. "gt:0",
  32. function ($attribute, $value, $fail) {
  33. $types = array_column(ChannelServic::getNavPagesType(),'value');
  34. if (!in_array($value,$types)) {
  35. $fail("小程序类型不正确");
  36. }
  37. },
  38. ],
  39. ];
  40. }
  41. /**
  42. * messages
  43. *
  44. * @return string[]
  45. */
  46. public function messages(): array
  47. {
  48. return [
  49. 'type' => '频道类型不正确',
  50. 'miniprogram_type' => '小程序类型不正确',
  51. 'status' => '状态值不正确',
  52. ];
  53. }
  54. }