I'm trying to create a page that will show the amount of approved posts and group them by created_at column.
When I use the code that I've written I get this error
ErrorException SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'blog.posts.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select * from
posts
wherestatus
= approved group bycreated_at
) (View: /home/workspace/Documents/projects/blog/Modules/Posts/Resources/views/index.blade.php)
Here is my code
$approved = Post::where('status', 'approved')->groupBy('created_at')->get();
dd($approved);