dimanche 4 février 2018

Laravel model: complex query from external database?

New to Laravel, be kind. :-)

I have an external read-only legacy database. I use a complex query to retrieve the "top products" from a Products table. This is an expensive query, which should be cached (only update once a day if necessary). The parameters for the query: top products since date xyz, max # of results (default: 500).

The database is completely read-only. It is not possible to create a view (which was the solution to a similar question).

I would like to be able to treat these top products as a regular model in Laravel. This so that I can apply relationships / filters. E.g. check Purchase model for purchases for a "top product", get "top products" that have vendor value "xyz".

What is the best approach?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire