I need to show the sum of the price
column of model Foo
. Right now I can do it with this.
public function calculate(Request $request)
{
return $this
->sum($request, Contribution::class, 'contribution_amount')
->dollars();
}
Which show the following output.
- For sum of
22
=>$22
- For sum of
3120
=>$3.10k
I need to just show $22
, $3120
without any formatting. I tried to override the aggregate function but it still doesn't give me the correct output format.
protected function aggregate($request, $model, $function, $column = null, $dateColumn = null)
{
$query = $model instanceof Builder ? $model : (new $model)->newQuery();
$column = $column ?? $query->getModel()->getQualifiedKeyName();
$previousValue = with(clone $query)->whereBetween(
$dateColumn ?? $query->getModel()->getCreatedAtColumn(), $this->previousRange($request->range)
)->{$function}($column);
return $this->result(
with(clone $query)->whereBetween(
$dateColumn ?? $query->getModel()->getCreatedAtColumn(), $this->currentRange($request->range)
)->{$function}($column)
)->previous($previousValue);
}
Can anyone give a pointer here?