我打电话产品的信息字段,你可以看到如下:处理失败的雄辩方法
$product->attributes->first()->attributeValues->where('locale',$iso);
基本上在$product
变量已经有关于产品的信息。
我使用$product->attributes->first()
来获得他的属性,并在得到它们后,我用->attributeValues->where('locale',$iso)
来获得他的值与特定的语言。
它输出的数据是好的,但只有属性存在,因为如果没有任何它没有,并且由于attributeValues
方法页面失败。
我该如何处理这种情况?
你在哪里打电话呢?在模型或控制器? – Laerte