0

每个人。我面临以下错误

htmlentities() expects parameter 1 to be string, object given (View: E:\accounting\resources\views\index.blade.php)

在 laravel 中运行此查询并且不知道我缺少什么时,请提供任何帮助。谢谢 查询:

 $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>
4

1 回答 1

0

您可以在打印$purchase->usd_total之前检查$purchase变量是否有数据

在您的查看页面中,您可以检查以下内容

@if(count($purchase)>0)

{{ number_format($purchase->usd_total,2) }}

@endif

当然你也可以使用php。我用过刀片 if

希望这会有所帮助。:) :) :)

于 2016-06-14T22:00:29.967 回答