Reputation: 126
I'm trying to display sum of some columns in laravel using query builder but getting this error:
htmlentities() expects parameter 1 to be string, object given
This is the query:
$purchase = DB::table('purchases')
->join('currencies', 'currencies.cur_id', '=', 'purchases.currency_id')
->selectRaw('purchases.*, currencies.currency ,SUM(purchases.quantity*unit_price) as total, SUM(purchases.c_price*quantity) as usd_total')
->first();
And view:
<div class="col-xs-8">
<p class="text-elg text-strong mb-0">
{{ number_format($purchase->usd_total,2) }}
</p>
<span>Purchases</span>
</div>
Upvotes: 0
Views: 45