Skip to content
Advertisement

Separate table for each year in Laravel

How can implement tables based on year in Laravel, like Orders2020, Orders2019, Orders2018 etc. And how to switch between?

Advertisement

Answer

I have a model with huge datas, and every month it will generate nearly 10 million+ records, so I split its table horizon too.

The solution is like this below,

In your Order model:

JavaScript

So you can get the table you want:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement