2017-08-12 28 views
1

我有存儲在MySQL中的文章。還存儲在數據庫中的圖像。使用{!! $ myarticle-> content !!}很好地顯示呈現的文章,但是如果我在存儲的文章中使用{{$ myImage}},它將被渲染爲不是像刀片變量那樣。Laravel - 使用從MySQL中查看的刀片語法

有沒有辦法將它插入或拉出MySQL,以便當它到達視圖時,它將作爲刀片變量?

回答

0
//fetch data in the controller and return to the blade using view 
    public function index() 
    { 
     $users = DB::table('users')->get(); 

     return view('user.index', ['users' => $users]); 
    } 
The get method returns an Illuminate\Support\Collection containing the results where each result is an instance of the PHP StdClass object. You may access each column's value by accessing the column as a property of the object: 
//by using this u can fetch result 
foreach ($users as $user) { 
    echo $user->name; 
} 
+0

我應該更清楚了。我可以存儲和檢索數據庫中的信息,沒有任何問題。我希望能夠在數據庫中存儲和渲染刀片語法。一旦我從MySQL獲得結果,刀片鬍鬚就會被忽略並呈現 - 不是預期的變量。 – briodev