如何在laravel 5.1中显示bootstrap成功消息

时间:2017-01-17 05:42:26

标签: php laravel-5.1

嗨朋友需要帮助如何在laravel 5.1中显示成功消息,我已经应用它正在工作但两次显示是什么原因。这是我的layout.balde.php代码

@if (session()->has('success'))
<div class="alert-success" id="popup_notification">
    <strong>{!! trans('main.message') !!}</strong>{{ session('success') }}
</div>

@endif 这是我的控制器页面代码:

  return Redirect::route($this->cdroute, array($customer_id))->with('success',trans($this->updatemsg));

2 个答案:

答案 0 :(得分:0)

试试这个:

//in controller
    return Redirect::route($this->cdroute, array($customer_id))->with('success',trans($this->updatemsg));

//in blade template
    @if (session('success'))
        <div class="alert alert-success">
            {{ session('success') }}
        </div>
    @endif

答案 1 :(得分:0)

试试这个:

控制器页面代码:

Session::flash('success',trans($this->updatemsg));
Redirect::route($this->cdroute, array($customer_id));

layout.balde.php代码

@if ( Session::has('success') )
   <div class="alert-success" id="popup_notification">
     {{ Session::get('success') }}
  </div>      
@endif