Level 104
PHP's number_format, no?
{{ number_format($model->col1_sum) }}
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a few columns that I caclculate their SUM using raw query:
MyModel::select(DB::raw(SUM(col1) as col1_sum, SUM(col2) as col2_sum)))->groupBy('col1_sum', 'col2_sum')->get();
Is it possible to add commas whenever needed (every 3 digits from the right if exist)
It is going to be displayed in Blade. Is my best option to use a new Blade directive, or there's a better option?
Ty
PHP's number_format, no?
{{ number_format($model->col1_sum) }}
Please or to participate in this conversation.