2017-01-17 67 views
0

嗨朋友需要幫助如何在laravel 5.1中顯示成功消息,我已經應用它正在工作,但兩次顯示是什麼原因。這是我的layout.balde.php代碼如何在laravel 5.1中顯示引導成功消息

@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)); 

回答

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 
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 
+0

先生,你明白我的問題,閃光燈消息顯示正常,但是當我插入顯示兩個時間之後的記錄,這是我的問題 –

+0

我想換個地方我打電話,所以這是顯示兩次 –

+0

的原因,但是當我更新我剛剛在我的控制器頁面中調用的記錄Session :: flash('success',trans($ this-> updatemsg)); Redire :: route($ this-> cdroute,array($ customer_id)); –