I had to browse through the github issues to find out that withCount is not supported in combination with ->search().
Consider the following example:
User::where('operator_id', 5)->withCount(['timeRegistrations AS time_sum' => function ($query) {
$query->select(DB::raw("SUM(time_spent) as time_sum"));
}])->search('%something%')->paginate();
What seems to happen is that the query seems to resolve to WHERE 'operator_id' = '%%something%%' which is the parameter that was passed to the search function.
I doubt if this can be fixed easily. However it would be nice if this was in the readme so people know what to avoid.
I had to browse through the github issues to find out that
withCount
is not supported in combination with->search()
.Consider the following example:
What seems to happen is that the query seems to resolve to
WHERE 'operator_id' = '%%something%%'
which is the parameter that was passed to the search function.I doubt if this can be fixed easily. However it would be nice if this was in the readme so people know what to avoid.