laravel基于Bootstrap的成功和失败的提示信息和验证提示信息
message.blade.php
<!-- 成功提示框 --> @if(Session::has("success")) <div class="alert alert-success alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> <strong>成功!</strong> {{Session::get('success')}} </div> @endif <!-- 失败提示框 --> @if(Session::has("error")) <div class="alert alert-danger alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> <strong>失败!</strong> {{Session::get('error')}} </div> @endif
validattor.blade.php
<!-- 所有的错误提示 --> @if(count($errors)) <!--展示第一条错误信息--> <div class="alert alert-danger"> <ul> <li>{{$errors->first()}}</li> </ul> </div> <!--遍历所有的错误信息--> <div class="alert alert-danger"> <ul> @foreach($errors->all() as $error) <li>{{$error}}</li> @endforeach </ul> </div> @endif
validation错误提示:
@if(count($errors)>0) <div class="alert alert-danger" role="alert"> @foreach($errors->all() as $error) <li>{{$error}}</li> @endforeach </div> @endif