如何通过Laravel 5.6中的错误修复Laravel组

如何通过Laravel 5.6中的错误修复Laravel组,laravel,Laravel,六, 我错误地面对拉威尔集团。 我可以通过改变来解决这个问题 'strict' => true, to 'strick'=>false 以下是我的sql查询: select `employee_id`, `section_id`, `out_time` from `attendances` where `employee_id` is not null and `out_time` is null group by `section_id` 它在sql命令下工作。 当我试图用这

六,
我错误地面对拉威尔集团。 我可以通过改变来解决这个问题

'strict' => true, to 'strick'=>false
以下是我的sql查询:

select `employee_id`, `section_id`, `out_time` from `attendances` where `employee_id` is not null and `out_time` is null group by `section_id`
它在sql命令下工作。 当我试图用这段代码运行laravel时,它显示错误。
Laravel控制器代码如下:

$attendances = DB::table('attendances')
            ->select('employee_id','section_id','out_time')
            ->where('employee_id', '!=', null)
            ->where('out_time', null)
            ->groupBy('section_id')->get();

运行此代码后显示错误,错误如下:


如何解决此问题?

尝试将值作为集合获取,然后将结果分组,即使用而不是查询生成器

因此,您的查询应该是:

$attendances = DB::table('attendances')
        ->select('employee_id','section_id','out_time')
        ->where('employee_id', '!=', null)
        ->where('out_time', null)
        ->get()
        ->groupBy('section_id');
$attendances = DB::table('attendances')
        ->select('employee_id','section_id','out_time')
        ->where('employee_id', '!=', null)
        ->where('out_time', null)
        ->get()
        ->groupBy('section_id');