Answer the question
In order to leave comments, you need to log in
How to see validation errors?
in the template before the form, the output of validation errors is registered
@if(count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach($errors->all() as $error)
<li>{{ $error}}</li>
@endforeach
</ul>
</div>
@endif
<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Requests\ContactRequest;
use App\Http\Controllers\Controller;
use Validator;
class ContactController extends Controller
{
public function show(Request $request, $id=FALSE) {
if($request->isMethod('post')) {
$validator = Validator::make($request->all(),[
'name'=>'required'
],$messages);
if($validator->fails()) {
return redirect()->route('contact')->withErrors($validator)->withInput();
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Why do it through Validator::make if it is possible through $request->validate(...), then you won't need to check with a redirect, it will do everything by itself.
I would
bb($validator);
I alternately inserted it in different places - I would test where exactly the plug is
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question