01 - BelongsTo vs BelongsToMany vs Polymorphic: 3 Examples
We found 20 results for "polymorphic relationships".
Polymorphic relations are challenging to understand at first glance. So, the best way to explain it is with examples
I get a lot of questions about database structure, and in this video I will practically test two different DB structures and we will try to see which is better: belongsTo with three columns, or polymorphic relations?
Polymorphic relations are one of the most difficult concept to understand for junior developers, and I tried to do it with a real-life example.
Polymorphic relationships are one of the most complex relationships in Laravel. In this post, let's examine eight examples from Laravel open-source projects and how they use them.
When structuring a database, similar relationships may repeat, like a Task may be assigned to a User, User Group, or User Role. Is it worth thinking about polymorphic? In this example, let's compare the performance and convenience to use.
In Laravel's many-to-many polymorphic relations, there is a situation where you can't get ALL records of different models by their "parent" record. Let me explain, and show the potential solution.
In Laravel Eloquent, polymorphic structure is probably slower for queries. But by how much? Let's measure.
I want to share my recent discovery, maybe it will be news to some of you as well.
A great example of reusable polymorphic relations is an open-source portal Laravel.io, let's take a look at its structure.
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:
Files in the example: