I would create a job that pulls the data from the api, and stores it in the local db, then query the local table only.
Oct 10, 2023
3
Level 3
Using Eloquent Model with additional data from API
Hi, We are currently using the basic structure of a typical Laravel application with the MVC pattern. Eloquent provides and stores data from mysql database via our Model (ex. Machines).
Now we'd like to use a REST API which provides (and stores) parts of a Machine object.
What's the best practise to compose those data from multiple sources, so we can still use the same methods in the controller like find(), create(), etc.?
I think we have to override those methods, but how should we compose those informations.
see Diagram: https://imgur.com/a/Egu9LkV
Machine Data via Eloquent from Database
- software_version
- software_architecture
- firmware_version
- ...
Machine Data from API
- serial_number
- owner_id
- machine_type
- ...
Please or to participate in this conversation.