Я хочу показать ошибку проверки, указав недопустимый вход на странице просмотра. Но сообщение об ошибке не отображается на странице просмотра. Если возможно, кто-то даст решение, пожалуйста.Laravel 5.2 Ошибки проверки, не появляющиеся в Blade
Вот контроллер:
public function saveStudent(Request $request){
$this->validate($request,[
'name' => 'required|max:120',
'email' => 'required|email|unique:users',
'phone' => 'required|min:11|numeric',
'course_id'=>'required'
]);
$user = new User();
$user->name= $request->Input(['name']);
$user->email= $request->Input(['email']);
$user->phone= $request->Input(['phone']);
$user->date = date('Y-m-d');
$user->completed_status = '0';
$user->course_id=$request->Input(['course_id']);
$user->save();
return redirect('success');
}
Вот страница вид:
<html>
<head>
<title> Create Course </title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container" >
<h3> Student Register </h3>
{!! Form::open(array('route' => 'saveUser','class'=>'form-horizontal','method'=>'POST')) !!}
{!! Form::token(); !!}
{!! csrf_field() ; !!}
<div class="form-group">
<label>Name</label>
<input type="text" name="name" class="form-control" placeholder="Name">
</div>
<div class="form-group">
<label>Email</label>
<input type="email" name="email" class="form-control" placeholder="email">
</div>
<div class="form-group">
<label>Phone Number</label>
<input type="text" name="phone" class="form-control" placeholder="phone">
</div>
<div class="form-group">
<label for="">Class</label>
<select class="form-control input-sm" name="course_id" >
@foreach($input as $row)
<option value="{{$row->id}}">{{$row->name}}</option>
@endforeach
</select>
</div>
<button type="submit" class="btn btn-default">Submit</button>
{!! Form::close() !!}
</div>
@if(count($errors)>0)
<div class="alert alert-danger">
<strong>Whoops!</strong> Enter Valid Input</br>
<ul>
@foreach($errors->all() as $error)
<li>{{$error}}</li>
@endforeach
</ul>
</div>
@endif
</body>
</html>
ли вы обернуть маршруты с ' web 'промежуточное звено? – Sovon
Да! Он находится только в середине промежуточного программного обеспечения в Интернете! – User57
Возможный дубликат [ErrorBag всегда пуст в Laravel 5.2] (http://stackoverflow.com/questions/36377420/errorbag-is-always-empty-in-laravel-5-2) – patricus