laravel非法字符串偏移量,以获取刀片上的数组和

时间:2017-12-14 18:52:02

标签: php laravel laravel-5

使用此代码从数据库获取数据后:

$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

0 个答案:

没有答案