我想有一个模型属性包含数组的文件从特定目录
public function getGalleryAttribute($value) {
return Storage::disk('storage')->files($value);
}
然后我输出在页
@foreach ($item->gallery as $img)
<img src="/storage/{{ $img }}" >
@endforeach
和我看到错误
Attempt to read property "gallery" on array (View: /var/www/site/resources/views/components/postpartials/gallery.blade.php)
我不明白是什么问题
if ($item->gallery->isNotEmpty()) {
}
尝试检查数组中是否存在gallery属性以及其中是否存储了某种数据使用dd($item);
好像打错了。问题结束