Рассчитайте общую сумму значений столбцовPhp

Кемеровские программисты php общаются здесь
Anonymous
Рассчитайте общую сумму значений столбцов

Сообщение Anonymous »

У меня есть таблица на моей странице лезвия, < /p>

Код: Выделить всё



Color
Total



@if ($counts)
@foreach ($counts as $item)

{{ $item->color }}
{{ $item->total }}

@endforeach
@endif


Я хочу показать общую сумму общей суммы столбца . Я погуглил для решения, но все предлагают использовать функцию Sum Summ Sum . Можно ли сделать это на странице лезвия?

Код: Выделить всё

public function get_color_distribution(Request $request)
{
$date_from = Carbon::parse($request->input('n_from_date'))->startOfDay();
$date_to = Carbon::parse($request->input('n_to_date'))->endOfDay();

$counts = Production::join('finishes', 'finishes.id', '=', 'productions.color')
->select(
DB::raw('count(*) as total'),
'finishes.description as color'
)
->whereDate('productions.created_at', '>=', $date_from)
->whereDate('productions.created_at', '

Подробнее здесь: [url]https://stackoverflow.com/questions/79756716/calculate-the-sum-total-of-column-values[/url]

Вернуться в «Php»