方法一:跳转到有错误信息的指定路由 return redirect(‘/admin/resource/showAddResourceView/’ . $customer_id) ->withErrors([‘此授权码已过期,请重新生成!’]); 方法二:跳转到上个页面,并携带错误信息 return back()->withErrors([‘此激活码已与该用户绑定过!’]); 方法三:validate验证(这种情况应该是...
if(!session('name')){returnredirect('book')->withErrors('请登录'); } 首先在后台使用withErrors放回错误信息 前台页面通过全局函数$errors接收错误信息,通过循环在页面展示 @foreach($errors->all()as$error){{$error}}@endforeach
代码语言:txt 复制 public function clearErrors() { session()->forget('errors'); return redirect()->back(); } 这样,当你访问clearErrors路由时,会话中的错误信息将被清除。 总结: Laravel 7中清除withErrors会话的步骤如上所述。通过将错误信息存储到会话中,并在视图文件中显示出来,你可以更好地处理表单...
方法一:跳转到指定路由,并携带错误信息 return redirect('/admin/resource/showAddResourceView/' . $customer_id) ->withErrors(['此授权码已过期,请重新生成!']); 1. 2. 方法二:跳转到上个页面,并携带错误信息 return back()->withErrors(['此激活码已与该用户绑定过!']); 1. 方法三:validate验证(这...
return redirect('/admin/resource/showAddResourceView/' . $customer_id) ->withErrors(['此授权码已过期,请重新生成!']); 方法二:跳转到上个页面,并携带错误信息 return back()->withErrors(['此激活码已与该用户绑定过!']); 方法三:validate验证(这种情况应该是最多的) ...
class LoginController extends Controller { public function login(Request $request) { $credentials = $request->only('email', 'password'); if (Auth::attempt($credentials)) { // 登录成功后的重定向路径 return redirect('/home'); } else { return redirect()->back()->withErrors(['message' =...
3use Illuminate\Support\Facades\Redirect; 4 5Route::post('/confirm-password', function (Request $request) { 6 if (! Hash::check($request->password, $request->user()->password)) { 7 return back()->withErrors([ 8 'password' => ['The provided password does not match our records.'...
我将Laravel 5.8 与自定义身份验证一起使用,因此,我需要使用Cache Tags。为了使其工作, myCACHE_DRIVE设置为array. 但是使用这种配置,我无法在重定向到视图时使 Flash 会话消息工作。 在CustomAuthController.php 我试过: return redirect() ->route('login') ...
3use Illuminate\Support\Facades\Redirect; 4 5Route::post('/confirm-password', function (Request $request) { 6 if (! Hash::check($request->password, $request->user()->password)) { 7 return back()->withErrors([ 8 'password' => ['The provided password does not match our records.'...
return redirect('/'); } 我也试过了,但没有成功,执行力达不到这里 $validator = $this->validate(); if($validator->fails()) { $this->emitSelf('validation-error'); return redirect('/register'); //->withErrors($validator) //->withInput(); ...