I have a database tables as followed
Posts Table | Comments Table | Users Table | Pages Table | Likables Table |
---|---|---|---|---|
id | id | id | id | id |
user_id | user_id | name | page_name | liker_id |
content | comment | liker_type | ||
created_at | created_at | likable_id | ||
likable_type |
likable_type column in Likables Table may be post or comment and liker_type column may be page or user.
I want to access the the collection of total likers as well as each Page or User from the Post or Comment models.
Similarly, I would like to get the collection of Posts or Comments that the User or Page liked.
Is it possible to have like this? How can I make the relationships for this scenario?