MiniprogramRequest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Modules\Manage\Http\Requests;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. use Modules\Manage\Enmus\MiniprogramType;
  5. use Illuminate\Validation\Rule;
  6. class MiniprogramRequest extends FormRequest
  7. {
  8. /**
  9. * Determine if the user is authorized to make this request.
  10. */
  11. public function authorize(): bool
  12. {
  13. return true;
  14. }
  15. /**
  16. * Get the validation rules that apply to the request.
  17. *
  18. * @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
  19. */
  20. public function rules(): array
  21. {
  22. return [
  23. 'name'=> 'required|max:50',
  24. 'play_name'=> 'required|max:100',
  25. 'company'=> 'required|max:255',
  26. 'type'=> [
  27. 'required',
  28. Rule::in( array_map( fn($item)=>$item->value(),MiniprogramType::cases())),
  29. ],
  30. 'appsecret'=>'required|min:30|max:64',
  31. 'appid'=>'required|unique:miniprogram|min:18|max:32',
  32. 'status'=>'in:0,1'
  33. ];
  34. }
  35. public function messages()
  36. {
  37. return [
  38. 'name.required'=>'小程序名称必填',
  39. 'appid.min'=>'appid太短',
  40. 'appid.max'=>'appid过长',
  41. 'appsecret.min'=>'appsecret太短',
  42. 'appsecret.max'=>'appsecret过长'
  43. ];
  44. }
  45. }