【发布时间】:2019-08-31 21:13:46
【问题描述】:
我将图像位置 url 存储到我的名为 images 的数据库列中。并且是这种形式... [“http://kizflex.local/properties/10.jpg”,”http://kizflex.local/properties/11.jpg”]
那么我如何遍历这个特定的列以获取每个地址并将其显示在我的视图中?请卡住我需要帮助。
@foreach($properties->all() as $property)
<h1>{{$property->property_title}}</h1>
@foreach (json_decode($property->property_image, true) as $image)
<img src="{{ $image[0] }}" alt="" width="100%">
@endforeach
@endforeach
【问题讨论】:
-
您是否收到错误消息?如果可以的话可以分享一下吗?如果不能,你能解释一下你现在得到了什么吗?
-
你可以使用 JSON -> array mutator 在这里找到laravel.com/docs/5.8/eloquent-mutators#attribute-casting