nova-issues
nova-issues copied to clipboard
Partition Metrics - Access nested JSON Field
- Laravel Version: ^10.0
- Nova Version: 4.26.5
- PHP Version: 8.2.4
- Database Driver & Version: pdo_mysql, mysqlnd 8.2.4
Description:
In my partition metric I want to access a nested JSON field.
public function calculate(NovaRequest $request) {
return $this->count($request, User::class, 'meta->notifications->newsletters');
}
However, I don't get any correct data back.
If I make a query directly to the database:
SELECT JSON_UNQUOTE(JSON_EXTRACT(meta, '$.notifications.newsletters')) AS opt, COUNT(*) as aggregate FROM users GROUP BY opt;
Do I get the following data:
opt | aggregate |
---|---|
true | 58 |
false | 13 |
NULL | 1 |