php - Laravel Eloquent Model Syntax error or access violation on groupBy
Solution:
When your group by 'group' you can have more than one id per group so it's a pb of logic, you cannot* have id in the select list.
*since your query cannot guess
2 solutions depending of what you want to do :
retrieve id from the select
add id to the group by
Answer
Solution:
Every column has to be in the GROUP By or have a aggregation function like in the example MIN(id)
public function index()
{
$settings = Setting::groupBy('group')->select('MIN(d) AS id,group as name')->orderBy('id', 'ASC')->get();
return view('settings.general'), compact('settings'));
}
Source