我正在尝试使用查询构建器显示laravel中的某些列的总和但是收到此错误:
htmlentities() expects parameter 1 to be string, object given
这是查询:
$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();
并查看:
<div class="col-xs-8">
<p class="text-elg text-strong mb-0">
{{ number_format($purchase->usd_total,2) }}
</p>
<span>Purchases</span>
</div>
答案 0 :(得分:1)
dd($ purchase-&gt; usd_total)你会找到原因。