Skip to content

Commit

Permalink
Use whereLike for case-insensitive search
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Nov 27, 2024
1 parent 130e1ae commit 5620bae
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Filters/Types/Like.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@

use Illuminate\Database\Eloquent\Builder;
use Orchid\Filters\BaseHttpEloquentFilter;
use Composer\InstalledVersions;
use Composer\Semver\VersionParser;

class Like extends BaseHttpEloquentFilter
{
public function run(Builder $builder): Builder
{
return $builder->where($this->column, 'like', '%'.$this->getHttpValue().'%');
if (InstalledVersions::satisfies(new VersionParser, 'laravel/framework', '>11.17.0')) {
return $builder->whereLike($this->column, $this->getHttpValue());
}

/**
* @deprecated logic for older Laravel versions
*/
return $builder->where($this->column, 'like', '%' . $this->getHttpValue() . '%');
}
}

0 comments on commit 5620bae

Please sign in to comment.