Php Laravel背包自定义搜索逻辑

Php Laravel背包自定义搜索逻辑,php,laravel,backpack-for-laravel,Php,Laravel,Backpack For Laravel,您好,我正在尝试通过背包生成的列进行排序和搜索 由于默认情况下不存在,我需要自己添加它,因此我尝试搜索的列是我在选择时创建的计算列: $this->crud->operation('list', function () { $this->crud->groupBy('email') ->select('*', DB::raw('count(*) as countedAttempts)); })

您好,我正在尝试通过背包生成的列进行排序和搜索

由于默认情况下不存在,我需要自己添加它,因此我尝试搜索的列是我在选择时创建的计算列:

 $this->crud->operation('list', function () {
            $this->crud->groupBy('email')
                ->select('*', DB::raw('count(*) as countedAttempts));
        });

    }

    protected function setupListOperation()
    {
        $this->crud->addColumn(['name' => 'countedAttempts', 'type' => 'text', 'label' => 'Total count',
            'orderable' => true,
            'searchLogic' => function ($query, $column, $searchTerm) {
                $query->orWhere('countedAttempts', 'like', '%'.$searchTerm.'%');
            },
            'orderLogic' => function ($query, $column, $columnDirection) {
                return $query->orderBy('countedAttempts', $columnDirection);
            },
        ]);
在添加附加操作并执行原始选择后,这对orderlogic有效,但对于搜索逻辑,我仍然得到错误:

未找到列:“where子句”中的1054未知列“countedAttempts”


我需要做什么?

不能在别名上使用where,必须使用Having子句