All individual subscriptions are 50% off this week only!

mstnorris
3 years ago

Games and Players (Users) for Table Tennis scores app (simple)

Posted 3 years ago by mstnorris

I have two models, Game, and User (a player).

In my games table, I store the ID of player_one_id, player_two_id, along with their scores, and the date that they played.

Firstly, I would like to know how to set up the relationships as a player (User) can either be player one or player two so it isn't a straight forward hasMany relationship.

Secondly, I would also like to know how to group by the day that games were played on when displaying all games. So for example:

Tue 29 Dec 2015

Mike 18 - 21 John

John 19 - 21 Ben

Mon 28 Dec 2015

Mike 21 - 19 John

Please sign in or create an account to participate in this conversation.