php - @error 指令未在 laravel 视图中显示错误
问题描述
我正在研究自定义 Laravel 登录实现。我从控制器返回错误如下:
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
// Authentication passed...
return redirect()->intended('surveys');
}else {
return redirect()->back()->withErrors(['email', 'The Message']);
}
这是我提取此错误的视图实现:
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
我只想用这种方式。由于代码最小化,不是显示错误的其他方法。我正在使用 Laravel 7.0+
解决方案
请再试一次:
$credentials = $request->only('email', 'password');
if (Auth::attempt($credentials)) {
// Authentication passed...
return redirect()->intended('surveys');
}else {
return redirect()->back()->withErrors(['email' => 'The Message']);
}
推荐阅读
- excel - Open SharePoint file into desktop version of Excel
- reactjs - 根据函数返回的内容渲染组件
- python - 创建的新列的值不正确
- python - 如何在 tf.estimator.BoostedTreesClassifier 中设置 n_batches_per_layer
- java - java - 如何将Object的属性值转换为Java中的数组?
- xamarin - Xamarin:禁用共享运行时时出现错误 XALNK7000
- tags - 有没有办法更改已创建资源的 aws 资源属性?
- automated-tests - 空手道 - 困难
- javascript - 命令行索引
- excel - 创建一个 while 循环,检查用户是否在 1.5 秒内选择了形状