I'm starting learning Laravel and I wonder about the way to retrieve some data. I have 4 tables
An Users may have multiple records. (Records has a foreign key of user) RecordsA has a foreign key of Records RecordsB has a foreign key of Records
I would like to retrieve records (A or B) from an User and I wonder what is the best way to do it.
Write functions to the user's repository getRecordA() and getRecordB() so that I could do in my controller,
$this->user->getRecordA() and user->getRecordB()
Write functions to recordA's repository and recordB's repository ?
So I will inject the id of the user in the query.
So in my controller, I could write
I'm asking that, because the user is the core of my app and I have many tables (among Records, RecordsA and RecordB) that are linked to my user and I'm affraid that my user table will be huge. However, for me it's intuitive to put all the related function to the user repository.
What do you think ? Could you please give the good practice ?