Skip to main content

Advanced Polymorphic: Many-to-Many

Premium
2:40

The Full Lesson is Only for Premium Members

Want to access all of our courses? (36 h 00 min)

You also get:

61 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Ravindrasinh Jadav avatar

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

Povilas Korop avatar

It's not photo_id, it's photoable_id

amauro 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?

Povilas Korop avatar

Good idea, that would be a good extra constraint.