NoticeSave.php 743 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Requests\Admin;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class NoticeSave extends FormRequest
  5. {
  6. /**
  7. * Get the validation rules that apply to the request.
  8. *
  9. * @return array
  10. */
  11. public function rules()
  12. {
  13. return [
  14. 'title' => 'required',
  15. 'content' => 'required',
  16. 'img_url' => 'nullable|url',
  17. 'tags' => 'nullable|array'
  18. ];
  19. }
  20. public function messages()
  21. {
  22. return [
  23. 'title.required' => '标题不能为空',
  24. 'content.required' => '内容不能为空',
  25. 'img_url.url' => '图片URL格式不正确',
  26. 'tags.array' => '标签格式不正确'
  27. ];
  28. }
  29. }