Closed kurucu closed 10 months ago
Well I've not been paying attention, you can do this. My way was as follows:
$data = Trend::query(
Model::query()
->withoutEagerLoads()
->withoutGlobalScopes()
)
->between(
start: now()->subYear(),
end: now(),
)
->perMonth()
->count()
->toArray();
I have a model that uses eager loading by default, which seems to trip Laravel Trend over, as Laravel injects a sub query into the model query when doing so.
The following should fix it:
There is the same problem with models that have scopes added, but these are more easily solved: