![]() Return $this->belongsToMany(Product::class) Īpp/Models/Product.php: class Product extends Model The main part here is to assign a many-to-many relationship - it can be done from either of "main" tables models.Īpp/Models/Shop.php: class Shop extends Model Ok, we have DB tables and migrations, now let's create models for them. Models for Many-to-Many Relationships: BelongsToMany You can add more fields if you want, then you need to add them to relationship assignment - we will discuss that later. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |