Skip to content

Commit 67a6b84

Browse files
committed
fix: adapt whereLike and orWhereLike to Laravel v11.17
1 parent 9e99d8a commit 67a6b84

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Query/BuilderWhere.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public function orWhereIntegerArrayMatches($column, string $query): static
6464
* @param Expression|string $column
6565
* @param Expression|string $value
6666
*/
67-
public function orWhereLike($column, $value, bool $caseInsensitive = false): static
67+
public function orWhereLike($column, $value, $caseSensitive = false): static
6868
{
69-
return $this->whereLike($column, $value, $caseInsensitive, 'or');
69+
return $this->whereLike($column, $value, $caseSensitive, 'or', false);
7070
}
7171

7272
/**
@@ -183,11 +183,11 @@ public function whereIntegerArrayMatches($column, string $query): static
183183
* @param Expression|string $value
184184
* @param string $boolean
185185
*/
186-
public function whereLike($column, $value, bool $caseInsensitive = false, $boolean = 'and'): static
186+
public function whereLike($column, $value, $caseSensitive = false, $boolean = 'and', $not = false): static
187187
{
188188
$type = 'like';
189189

190-
$this->wheres[] = compact('type', 'column', 'value', 'caseInsensitive', 'boolean');
190+
$this->wheres[] = compact('type', 'column', 'value', 'caseSensitive', 'boolean', 'not');
191191
$this->addBinding($value);
192192

193193
return $this;

src/Query/GrammarWhere.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ public function whereAny(Builder $query, $where): string
4646
/**
4747
* Compile a "like" clause.
4848
*
49-
* @param array{caseInsensitive: bool, column: string, value: mixed} $where
49+
* @param array{caseSensitive: bool, column: string, value: mixed} $where
5050
*/
5151
public function whereLike(Builder $query, $where): string
5252
{
53-
return match ((bool) $where['caseInsensitive']) {
54-
true => "{$this->wrap($where['column'])} ilike {$this->parameter($where['value'])}",
55-
false => "{$this->wrap($where['column'])} like {$this->parameter($where['value'])}",
56-
};
53+
$where['operator'] = $where['not'] ? 'not ' : '';
54+
$where['operator'] .= $where['caseSensitive'] ? 'like' : 'ilike';
55+
56+
return "{$this->wrap($where['column'])} {$where['operator']} {$this->parameter($where['value'])}";
5757
}
5858

5959
/**

0 commit comments

Comments
 (0)