Good practices in a GET (Laravel API) request [closed]

0

Hello, I have a table with user login data, and this table is related to several other tables (FK). I'm making an API using Laravel, but a question has arisen. If I make a GET in the Login table using the user ID, which is best as good practice: 1. Make a relationship and when I give a GET in the Login table, using the user ID, I already see the data of all related tables. OR 2. A "GET", for each table that has the FK with the ID of the Login table, that way I would pass an ID on the request and each table would "query" individually. What I would like to do is to have an area with the data of these user tables, so that it could change, delete, read ... but as they are distributed in other tables, I do not know what is best practice or what is not so heavy.

    
asked by anonymous 13.11.2018 / 01:52

1 answer

0

It depends on your need. If you just want to get the essential user data after login it would be a good practice to search the bank for a single time, thus avoiding unnecessary requests. As you already have the relationships, I would not have the pq to fetch table from table at login time. In changing the data, you can send a json with the data to be modified and in the controller validate that data for which tables they are part of.

    
13.11.2018 / 17:44