You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 1, 2024. It is now read-only.
This becomes even more powerful when using joins for individual rows:
57
+
58
+
```php
59
+
$users = User::query()
60
+
->join('statistics', function ($join) {
61
+
$join->on('users.id', '=', 'statistics.id')
62
+
->where('statistics.table', 'users');
63
+
})
64
+
->get(['users.name', DB::raw('`values`->"$.post_count" AS `posts`')])
65
+
->orderByRaw('`values`->"$.post_count" DESC')
66
+
```
67
+
68
+
| Name | Posts |
69
+
| ----- | ----- |
70
+
| John | 6 |
71
+
| Fred | 4 |
72
+
| Dave | 1 |
73
+
46
74
## How does it work?
47
75
48
76
The package will automatically register and migrate a `statistics` table to your database. This table then serves as a repository for aggregated values. You can then easily join records to this table to get the associated metrics you need.
0 commit comments