I have a sales data on a table I want to present in chart like this
{
"jan": 34,
"feb": 30,
"mar": 41,
"apr": 18,
"may": 26,
"jun": 21
}
How do I query this data with eloquent using created_at to count and group them based on month?
@tykus I have a purchases table and what I want to achieve is to show every seller the sales count of months from Jan-Dec using the created_at(Which is the time the product was sold and saved on the table).
@juliofagundes Thanks but this is only giving me the count for current month, I want to get counts for Jan, feb to Dec as a key and value e.g. [{ month: "jan", total: 20}, {month: "feb", total: 15}]