laravel使用witherror返回错误

        if(!session('name')){
                return redirect('book')->withErrors('请登录');
        }    

首先在后台使用withErrors放回错误信息

前台页面通过全局函数$errors接收错误信息,通过循环在页面展示

    @foreach($errors->all() as $error)
    <h3>{{ $error }}</h3>
    @endforeach

猜你喜欢

转载自www.cnblogs.com/duansong/p/12188933.html