php - 如何只显示1条Flash消息 - Laravel

时间:2017-09-12 06:10:02

标签: php laravel flash-message

你好我在laravel的新手所以我真的需要一些帮助。我想创建一个只显示1条flash消息的代码。在我的情况下,当我更新用户或商店时会出现2个Flash消息"用户更新成功"和"商店更新成功"。我只想显示一条Flash消息。

这是我的代码

<div class="content">
  @include('flash::message')
   @include('adminlte-templates::common.errors')
   <div class="box box-primary">
       <div class="box-body">
           <div class="row">
                {!! Form::model($users, ['route' => ['users.update', $store->user_id], 'method' => 'patch']) !!}

                    @include('users.fields',['user'=>$users])

               {!! Form::close() !!}
             </div>
       </div>
   </div>

<div class="content">
@include('flash::message')
   @include('adminlte-templates::common.errors')
   <div class="box box-primary">
       <div class="box-body">
           <div class="row">
               {!! Form::model($store, ['route' => ['stores.update', $store->id], 'method' => 'patch' , 'files' => true]) !!}

                    @include('stores.fields')


               {!! Form::close() !!}                   
           </div>
       </div>
   </div>

This is the view of 2 flash message from User

This is the view of 2 flash message from Store

1 个答案:

答案 0 :(得分:0)

从div中删除所有Flash消息,并仅添加上面的单个Flash消息。

//add only this above all div and remove others
@include('flash::message')

<div class="content">
    @include('adminlte-templates::common.errors')
    <div class="box box-primary">
        <div class="box-body">
           <div class="row">
               {!! Form::model($users, ['route' => ['users.update', $store->user_id], 'method' => 'patch']) !!}

                @include('users.fields',['user'=>$users])

               {!! Form::close() !!}
           </div>
       </div>
   </div>
</div>

<div class="content">
   @include('adminlte-templates::common.errors')
   <div class="box box-primary">
       <div class="box-body">
           <div class="row">
               {!! Form::model($store, ['route' => ['stores.update', $store->id], 'method' => 'patch' , 'files' => true]) !!}

                @include('stores.fields')


               {!! Form::close() !!}                   
           </div>
       </div>
   </div>
</div>