Skip to content

Commit

Permalink
lower key
Browse files Browse the repository at this point in the history
  • Loading branch information
esbenp committed Nov 20, 2022
1 parent 94f1001 commit 49ba54e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,24 @@ protected function getCreatedAtColumn()
protected function applyWhereArray($query, array $clauses)
{
foreach ($clauses as $key => $value) {
preg_match('/NOT\:(.+)/', $key, $matches);

$not = false;
if (isset($matches[1])) {
$lower = false;

if (preg_match('/NOT\:/', $key)) {
$not = true;
$key = $matches[1];
}
if (preg_match('/LOWER\:/', $key)) {
$lower = true;
}

$key = preg_replace(
['/NOT\:/', '/LOWER\:/'],
['', ''],
$key
);

if ($lower) {
$key = \DB::raw(sprintf('LOWER(%s)', $key));
}

if (is_array($value)) {
Expand Down

0 comments on commit 49ba54e

Please sign in to comment.