Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Eldair's avatar

Custom withSum query

Hello,

Can a query like the one below be written using withSum method or in a more eloquent way?

DB::raw('(select sum(JSON_LENGTH(`stores`.`baskets`)) from `stores` where `users`.`id` = `stores`.`user_id`) as `baskets_count`')
0 likes
0 replies

Please or to participate in this conversation.