使用此代码从数据库获取数据后:
$recipes = ContentCategories::find('12')->contents->take(4);
并显示$recipes
的第一项:
dd($recipes[0]->featured_images['thumbnail']);
我得到了这个结果:
"/uploads/contents/63648415249878355.jpg"
完整结果:
array:2 [▼
"images" => array:1 [▼
"original" => "/uploads/contents/63648415249878355.jpg"
]
"thumbnail" => "/uploads/contents/63648415249878355.jpg"
]
现在,当我尝试使用$recipes
在刀片上显示@foreach
时,我无法显示thumbnail
并收到此错误:
Illegal string offset 'thumbnail'
我在刀片上的代码:
@foreach($recipes as $recipe)
<img src="{{$serverInformation->address}}{{$recipe->featured_images['thumbnail']}}"/>
@endforeach