jarektkaczyk / eloquence-base

base for the Eloquence extensions + Searchable
https://softonsofa.com
MIT License
77 stars 69 forks source link

Add to readme that "withCount" is not supported #21

Closed bert-w closed 4 years ago

bert-w commented 4 years ago

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.

jarektkaczyk commented 4 years ago

thanks for feedback @bert-w , PR for the readme would be lovely

bert-w commented 4 years ago

https://github.com/jarektkaczyk/eloquence/wiki/Builder-searchable-and-more

Added it to this page.