Returning multiple models in polymorphic relationship #45239
Unanswered
misbahansori
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone, given I have a database schema like this :

a user can like both an album and an image.
to retrieve the relationship in the user model I can do something like this :

I wonder how I can use a polymorphic relationship in Laravel to create a method called

$user->likes()
that will return an instance of the album and/or image model.Beta Was this translation helpful? Give feedback.
All reactions