11 - DB Refactoring: From BelongsTo to BelongsToMany
We found 17 results for "many-to-many".
Now, let's look at the polymorphic relation, which is a bit more complex: a many-to-many polymorphic relation. Suppose we look at the photos table from a previous lesson example
Today I want to talk about a feature of Laravel which is really useful but can be potentially difficult to understand at first. Pivot table is an example of intermediate table with relationships between two other "main" tables.
Default belongsToMany relationship in Laravel works really well - you can easily attach, detach or sync records. But what if you want to order pivot records by newest or oldest? This article will show you how.
Recently I've found a small detail in Laravel documentation which I want to share with you. Apparently, it's possible to filter pivot tables additionally, if needed. Let me show you how.
This is a deep dive into belongsToMany Relationships in Laravel with examples - from simple, to much more complex.
What if you have a belongsToMany relationship, and want to add the extra field(s) to the pivot table? In this video, I will show you how to do it, step-by-step: migration, model, form, controller.
Files in the example:
Files in the example:
Files in the example:
Files in the example:
Files in the example:
Files in the example:
Files in the example:
Files in the example:
Files in the example: