多对多关系, class Product extends Model { public function attributes() { return $this->belongsToMany(Attribute::class, 'sell_goods_attr', 'goods_id', 'attr_id'); } } $products = Product::query()->with('attributes')->get();
多对多关系,