1 @if ($errors->any())
2 @foreach ($errors->all() as $error)
3 <div>{{$error}}</div>
4 @endforeach
5 @endif
6
1/**
2 * Store a new blog post.
3 *
4 * @param Request $request
5 * @return Response
6 */
7
8public function store(Request $request)
9{
10 $validatedData = $request->validate([
11 'title' => 'required|unique:posts|max:255',
12 'body' => 'required',
13 ]);
14
15 // The blog post is valid...
16}
1
2@if ($errors->any())
3 <div class="alert alert-danger">
4 <ul>
5 @foreach ($errors->all() as $error)
6 <li>{{ $error }}</li>
7 @endforeach
8 </ul>
9 </div>
10@endif
11
1$rules = [
2 'name' => 'required',
3 'email' => 'required|email',
4 'message' => 'required|max:250',
5 ];
6
7 $customMessages = [
8 'required' => 'The :attribute field is required.'
9 ];
10
11 $this->validate($request, $rules, $customMessages);
1$rules = [
2 'name' => 'required',
3 'email' => 'required|email',
4 'message' => 'required|max:250',
5 ];
6
7 $customMessages = [
8 'required' => 'The :attribute field is required.'
9 ];
10
11 $this->validate($request, $rules, $customMessages);
12