2016-07-03 24 views
1

當我點擊results2刀片中的鏈接時,傳入變量(包含「測試文本」)傳遞正常,但此值不會顯示在儀表板2刀片中。傳入的變量未顯示在刀片​​中 - laravel

在結果2刀片鏈接:

在Dashboard2視圖
<a href="{{route('dashboard2',['wordsRow'=> $wordsRow->body])}}">{{$wordsRow->body}}</a> 

@if (isset($wordsRow)) 
      <header><h3>{{$wordsRow}}</h3></header> 
@endif 

的Dashboard2的網址:

http://localhost/xxxxxxx/dashboard2?wordsRow=Test+text

任何幫助確定爲什麼 '測試文本'沒有顯示在dashboard2視圖中?

回答

0

嘗試

@if (Request::has('wordsRow')) 
      <header><h3>{{Request::get('wordsRow')}}</h3></header> 
@endif 
+0

語法錯誤,意外';'在行中:@if(Request :: has('wordsRow')) –

+0

在被rap-s-h編輯之後工作 –

0

我從來沒有見過的地方,Laravel自動將$ _GET變量傳遞給視圖。那麼將這些變量傳遞給視圖的代碼在哪裏?

+0

公共函數postWords(請求$請求) \t \t { $體= $請求[ '體']; $ wordsRow = Words :: where(DB :: raw('body'),'LIKE',「%{$ body}%」) - > get(); $ words = new Words(); $ words-> body = $ body; $ request-> user() - > words() - > save($ words); return view('results2',[ \t \t'wordsRow'=> $ wordsRow]); \t \t} –

+0

那麼,你如何將變量傳遞給dashboard2-view仍然是缺失的。也許從huuuk的下面的答案已經幫助你。 – d33k4y