Can someone explain the difference between hasMany and belongsTo in Laravel? I'm confused about when to use which.
Solved
2 Answers
6
To add to that, the belongsTo side is always where the foreign key column is stored in the database. So if your posts table has a user_id column, then Post belongsTo User.