Have you tried a forum search, as it's been covered, like https://laracasts.com/discuss?q=three+table
What type of relations should I use?
Hi,
I'm not sure if "relations" is the right word, but let me try explain what I need to do.
I have these 3 tables that is related to my problem: companies, users and notifications.
A user signup to my app and can use it for different tasks. One of those tasks, are notifications. The user can choose what type of notifications we would like to receive from each company (if any). Users can set individual notifications-settings for each company that he is associated with. He might want to be notified when "Company A" has new product releases and sales, but he does not want the newsletter. Another user might have other settings.
How should I handle this and what is this type of.... method/function.... called? I was planning to add all the different "relations" to the notifications table, but not sure if that is a good idea or not.
Any suggestions how to keep track of all this?
Where are the notifications coming from? Is the database a company and user database? Seems like a company has notification which in turn has users for those notifications. But go through the docs and work some of the examples. Could be a has many through, not sure.
https://laravel.com/docs/5.4/eloquent-relationships#has-many-through
and see
Please or to participate in this conversation.