Skip to content

Commit

Permalink
Merge pull request #4382 from staudenmeir/where-json-contains
Browse files Browse the repository at this point in the history
[5.6] Add whereJsonContains() queries
  • Loading branch information
taylorotwell committed Jul 15, 2018
2 parents 27dae72 + b13ad1e commit fe47169
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ The query above will produce the following SQL:
<a name="json-where-clauses"></a>
### JSON Where Clauses

Laravel also supports querying JSON column types on databases that provide support for JSON column types. Currently, this includes MySQL 5.7 and PostgreSQL. To query a JSON column, use the `->` operator:
Laravel also supports querying JSON column types on databases that provide support for JSON column types. Currently, this includes MySQL 5.7, PostgreSQL, and SQL Server 2016. To query a JSON column, use the `->` operator:

$users = DB::table('users')
->where('options->language', 'en')
Expand All @@ -478,6 +478,18 @@ Laravel also supports querying JSON column types on databases that provide suppo
$users = DB::table('users')
->where('preferences->dining->meal', 'salad')
->get();
You may use `whereJsonContains` to query JSON arrays:

$users = DB::table('users')
->whereJsonContains('options->languages', 'en')
->get();

MySQL and PostgreSQL support `whereJsonContains` with multiple values:

$users = DB::table('users')
->whereJsonContains('options->languages', ['en', 'de'])
->get();

<a name="ordering-grouping-limit-and-offset"></a>
## Ordering, Grouping, Limit, & Offset
Expand Down

0 comments on commit fe47169

Please sign in to comment.