spatie / laravel-query-builder

Easily build Eloquent queries from API requests
https://spatie.be/docs/laravel-query-builder
MIT License
4.02k stars 395 forks source link

Add BeginsWithStrict filter #821

Closed danilopinotti closed 1 year ago

danilopinotti commented 1 year ago

Introduction

The current "FiltersPartial" filter is very useful, but, it has some performance issues when we use it in a table with many data (see #820).

This PR introduces the "beginsWithStrict" filter, which may be used in situations described before.

In addition, this PR also allows us to extend the PartialFilter to change only the "where" clause applies (method getWhereRawParameters), making it possible implements other cases, like beginsWith, endsWith, endsWithStrict, etc.

Using

$users = QueryBuilder::for(User::with('media'))
    ->allowedFilters([
        AllowedFilter::beginsWithStrict('name'),
    ])
   // ...

TODO

Related

Closes #820

oceanapplications commented 1 year ago

Merging this would make my day :)

AlexVanderbist commented 1 year ago

Good addition, thanks!