Skip to content

Commit 2d98e85

Browse files
[12.x] Sorting by JSON columns (#10547)
* Sorting by JSON columns. * Update queries.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent a7045cc commit 2d98e85

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

queries.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,15 @@ $users = DB::table('users')
11301130
->get();
11311131
```
11321132

1133+
Finally, using the `->` operator, the results can be sorted by a value within a JSON column:
1134+
1135+
```php
1136+
$corporations = DB::table('corporations')
1137+
->where('country', 'US')
1138+
->orderBy('location->state')
1139+
->get();
1140+
```
1141+
11331142
<a name="latest-oldest"></a>
11341143
#### The `latest` and `oldest` Methods
11351144

0 commit comments

Comments
 (0)