用户可以选择他想要查看的帖子类型。所以我创建了一个数据透视表posttype_user。现在我可以保存绑定到用户的所选postTypes。function users() return $this->belongsToMany(User::class);Post模型有一个带有postType_id的外键以及模型中的这种关系: public function postType()
我有3个与这个问题相关的模型:国家、制造商和地区。 为了解决这个问题,我简化了表格。我不认为表中的任何其他东西或任何其他模型与这个问题有任何关系。目前模型之间的关系是这样的; Country.php public function manufacturers() return $this->hasMany(Manufacturer::`manufacturer_id` as `laravel_through_key` from `co
我正在尝试创建一个简单的表之间的关系: - attribute_products - name
id price 用于链接它们的数据透视表->belongsToMany(Product::Class,'attribute_product_values','attribute_id','product_id');
} 如何从透视表中获取
我有laravel网络应用程序,并在离子与sqlite数据库框架实施它。如何查询关系数据库。例如,subjects->belongsToMany->students在此关系中,laravel运行两个查询(根据laravel-debug)
1. select * from "subjects"subject_id" as "pivot_subject_id", "student_subject&qu