Flowframe / laravel-trend

Generate trends for your models. Easily generate charts or reports.
MIT License
607 stars 64 forks source link

Conflict between date and created_at column #68

Open simonelepore opened 1 week ago

simonelepore commented 1 week ago

In two of my projects I've had the same issue. If I have a table with both a 'date' column and the default 'created_at' column, the Trend query will not work. I think it's because the alias 'date' that is internally used in the query conflicts with the actual other 'date' column (when it performs a group by and order by 'date').

In fact, if I change name to the 'date' column to something else, it will work. Or if I set the mysql 'strict' property to false in database.php

Is there a way to fix this? thank you!

FortuneV13 commented 6 days ago

I can confirm the same issue here.

simonelepore commented 5 days ago

I also discovered something else.. if you use Trend::query (to chain where's etc., instead of Trend::model) while you have both a created_at and date column (and 'strict' property to false), the results of the trend will be completely messed up 😅

plus, I discovered that it is generally not a good idea to turn that property to false