我的模型:class Product extends Model{ protected $table = 'Products'; protected $fillable = ['product_code', 'type', 'name', 'description', 'price', 'discount', 'image', 'image_alt']; public function products() { return $this->hasMany('App\ProductSpecifics'); }}我的控制器代碼:public function product($code){ $product = Product::where('product_code',$code)->get(); $productSpec = ProductSpecifics::where('product_code',$code)->get(); var_dump($product->name); return view('pages.product', compact('product','productSpec'));}錯誤: 此集合實例上不存在屬性 [名稱]我嘗試使用 dd($product) 并注意到其中有很多信息。如何只提取名稱、類型等屬性?
添加回答
舉報
0/150
提交
取消