2017-08-12 103 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