Recently encountered a problem in the background interface of an app.
Currently, the server where the article table resides is as a separate node, while the user table is on another node server.
Article Server
User server
The problem now is that the article server accepts the USER_ID from the app client, and then queries it only by writing the associated query and then flattening out the format of the JSON response package to return. Unable to enjoy the convenience of the Laravel model relationship, rather than elegant.
Is there any way to use the model without a table?
Reply content:
Recently encountered a problem in the background interface of an app.
Currently, the server where the article table resides is as a separate node, while the user table is on another node server.
Article Server
User server
The problem now is that the article server accepts the USER_ID from the app client, and then queries it only by writing the associated query and then flattening out the format of the JSON response package to return. Unable to enjoy the convenience of the Laravel model relationship, rather than elegant.
Is there any way to use the model without a table?
You are the equivalent of a small distributed system, ah, two servers in the middle or in the interface or service to associate a better way.
There is no need to use many-to-many models, and the relational model of Laravel cannot handle these complex scenarios.
It is not considered that the use of the model relationship is elegant, the decoupling and service between the system, the interface is the more elegant implementation of the scheme.
Another question, if your article table often use user_id, why not add a user_id in the article Table redundant field?