Skip to content

Commit

Permalink
Add includes / doesnt_include query conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Oct 25, 2023
1 parent 0c1bb56 commit 1b34b40
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Tags/Concerns/QueriesConditions.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ protected function queryCondition($query, $field, $condition, $value)
return $this->queryInCondition($query, $field, $value);
case 'not_in':
return $this->queryNotInCondition($query, $field, $value);
case 'includes':
return $this->queryIncludesCondition($query, $field, $value);
case 'doesnt_include':
return $this->queryDoesntIncludeCondition($query, $field, $value);
case 'starts_with':
case 'begins_with':
return $this->queryStartsWithCondition($query, $field, $value);
Expand Down Expand Up @@ -161,6 +165,16 @@ protected function queryNotInCondition($query, $field, $value)
return $query->whereNotIn($field, $value);
}

protected function queryIncludesCondition($query, $field, $value)
{
return $query->whereJsonContains($field, $value);
}

protected function queryDoesntIncludeCondition($query, $field, $value)
{
return $query->whereJsonDoesntContain($field, $value);
}

protected function queryStartsWithCondition($query, $field, $value)
{
return $query->where($field, 'like', "{$value}%");
Expand Down

0 comments on commit 1b34b40

Please sign in to comment.