dimanche 15 janvier 2017

Laravel Model changing to API


I have a question in regards to design/refactoring an existing app. My existing app is in Laravel. We have models like User, which you would imagine be linked to the Users table in the database.
Now I am planning to move this User table to an external database, which can be reached from my application with an API call.
In all the Different parts of the application there are calls to the Current User Model like User::find(Id). This wont work anymore since now Users table is not there anymore in the database.

1st Question: how to accomplish the above by changing the model reference to call an API instead of a DB table. Is there any design pattern that can be leveraged so that I dont have to change all the User::find in all of the applications.

2nd Question: How would you handle places where the table is directly referenced by joins. Like table.x = User.x

Any help/guidance would be appreciated. Thanks

Aucun commentaire:

Enregistrer un commentaire