Courses

Eloquent: The Expert Level (Laravel 9)

Advanced Polymorphic: Many-to-Many

Previous: Polymorphic Relations: Explained with Example
avatar

Shouldn't the pivot table have model_id and model_type instead of just photo_id ?

avatar

It's not photo_id, it's photoable_id

avatar
You can use Markdown
avatar

shouldn't there be a unique constraint or index for all three fields (photo_id, photoable_it and photoable_type) to avoid multiple assignements of one photo to a user?

avatar

Good idea, that would be a good extra constraint.

avatar
You can use Markdown
avatar
You can use Markdown