Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. namespace AppHttpRequests;
  2.  
  3. use AppHttpRequestsRequest;
  4.  
  5. class CreateArticleRequest extends Request
  6. {
  7. /**
  8. * Determine if the user is authorized to make this request.
  9. *
  10. * @return bool
  11. */
  12. public function authorize()
  13. {
  14. return true;
  15. }
  16.  
  17. /**
  18. * Get the validation rules that apply to the request.
  19. *
  20. * @return array
  21. */
  22.  
  23. public function rules()
  24. {
  25. return [
  26. 'title' => 'required|min:3',
  27. 'body' => 'required',
  28. 'published_at' => 'required|date'
  29. ];
  30. }
  31. }
  32.  
  33. public function create()
  34. {
  35. return view('articles.create');
  36. }
  37.  
  38. public function store(CreateArticleRequest $request)
  39. {
  40. Article::create($request->all());
  41.  
  42. return redirect('articles');
  43. }
  44.  
  45. {{ dd($errors->all()) }}
  46. @if ($errors->any())
  47. <ul class="alert alert-danger">
  48. @foreach ($errors->all() as $error)
  49. <li>{{ $error }}</li>
  50. @endforeach
  51. </ul>
  52. @endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement