I see many questions come up with the error:
SELECT list is not in GROUP BY clause and contains nonaggregated column .......
Many answers are telling the poster to change strict mode from true to false in the database config file.
But you can just do this for one query only by adding before the query:
config()->set('database.connections.your_connection.strict', false); // change your_connection to actual connection // then run your query
That way if only needed for one query no need to change it in config/database.php