1@if($errors->any())
2 <div class="alert alert-danger">
3 <p><strong>Opps Something went wrong</strong></p>
4 <ul>
5 @foreach ($errors->all() as $error)
6 <li>{{ $error }}</li>
7 @endforeach
8 </ul>
9 </div>
10@endif
11
12@if(session('success'))
13 <div class="alert alert-success">{{session('success')}}</div>
14@endif
15
16@if(session('error'))
17 <div class="alert alert-danger">{{session('error')}}</div>
18@endif
19
1@if($errors->has())
2 @foreach ($errors->all() as $error)
3 <div>{{ $error }}</div>
4 @endforeach
5@endif
1public function store(Request $request)
2{
3 $validator = Validator::make($request->all(), [
4 'title' => 'bail|required|max:255',
5 'body' => 'required',
6 ]);
7
8 // Check validation failure
9 if ($validator->fails()) {
10 // [...]
11
12 foreach($validator->messages()->getMessages() as $field_name => $messages) {
13
14 // Go through each message for this field.
15 foreach($messages AS $message) {
16 echo '***********'.$message.'***********<br>';
17 }
18 }
19 }
20
21 // Check validation success
22 if ($validator->passes()) {
23 // [...]
24 }
25
26 // Retrieve errors message bag
27 $errors = $validator->errors();
28}
1@if($errors->any())
2 {{ implode('', $errors->all('<div>:message</div>')) }}
3@endif
1<!-- /resources/views/post/create.blade.php -->
2
3<h1>Create Post</h1>
4
5@if ($errors->any())
6 <div class="alert alert-danger">
7 <ul>
8 @foreach ($errors->all() as $error)
9 <li>{{ $error }}</li>
10 @endforeach
11 </ul>
12 </div>
13@endif
14
15<!-- Create Post Form -->