0
申し訳ありませんが、私はlaravel 5の初心者です。登録フォームの検証を試みますが、エラーメッセージは表示されません。 エラーが表示されない理由を考えてください。助けてください。Laravel 5がエラーメッセージを表示しないことを確認します
ありがとうございます。ここで
は私のコードです
ビュー
<form role="form" method="post" action="{{ url('/backoffice/register') }}">
<div class="form-group{{ $errors->has('fullname') ? ' has-error' : '' }}">
<label for="name">Full Name</label>
<input type="text" name="fullname" class="form-control" id="fullname" value="{{ old('fullname') ?: '' }}" placeholder="Enter your fullname">
@if ($errors->has('fullname'))
<span class="help-block">{{ $errors->first('fullname') }}</span>
@endif
</div>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<label for="email" class="control-label">Your email address</label>
<input type="text" name="email" class="form-control" id="email" value="{{ old('email') ?: '' }}" placeholder="Enter your email">
@if ($errors->has('email'))
<span class="help-block">{{ $errors->first('email') }}</span>
@endif
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<label for="password" class="control-label">Choose a password</label>
<input type="password" name="password" class="form-control" id="password" placeholder="Enter your password">
@if ($errors->has('password'))
<span class="help-block">{{ $errors->first('password') }}</span>
@endif
</div>
<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">
<label class="control-label">Confirm Password</label>
<input type="password" class="form-control" name="password_confirmation" placeholder="Re-Enter your password">
@if ($errors->has('password_confirmation'))
<span class="help-block">
<strong>{{ $errors->first('password_confirmation') }}</strong>
</span>
@endif
</div>
<input type="hidden" name="activated" value="0">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button type="submit" class="btn btn-warning btn-sm">Submit</button>
<button type="reset" class="btn btn-default btn-sm">Reset</button>
</form>
コントローラ
public function postRegister(Request $request) {
$this->validate($request, [
'email' => 'required|email|max:255',
'password' =>'required|alphaNum|Between:4,8|Confirmed',
'password_confirmation'=>'required|alphaNum|Between:4,8',
'fullname' => 'required|max:255',
'activated' => 'required',
]);
Admin::create([
'email' => $request->input('email'),
'password' => $request->input('password'),
'fullname' => $request->input('fullname'),
'activated' => $request->input('activated')
]);
return redirect('backoffice/register')->with('info', 'register successfully!');
}
ルート
Route::get('backoffice/register', '[email protected]');
Route::post('/backoffice/register', '[email protected]');