voten
voten copied to clipboard
voten/app/Traits/CachableChannel.php has group by error
Illuminate/Database/QueryException with message 'SQLSTATE[42803]: Grouping error: 7 ERROR: column "suggesteds.id" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: select "id", "channel_id" from "suggesteds" group by "channe... ^ (SQL: select "id", "channel_id" from "suggesteds" group by "channel_id")'
id caused from
public function getDefaultChannels()
{
return Cache::remember('default-channels-ids', 60 * 60 * 24, function () {
return \App\Suggested::groupBy('channel_id')->select('id', 'channel_id')->pluck('channel_id');
});
}
it should be
\App\Suggested::groupBy('channel_id')->select('channel_id')->pluck('channel_id')
or
\App\Suggested::distinct('channel_id')->select('channel_id')->pluck('channel_id')