2016-06-14 92 views
0

每个人。我面临着以下错误如何处理Laravel中的htmlentities()异常

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> 

回答

0

您可以检查$购买变量是否有数据或不打印$ purchase-> usd_total

前在您的查看页面中,您可以查看类似以下的内容

@if(count($purchase)>0) 

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

@endif 

当然你可以使用PHP 如果 too.I已经使用刀片如果

希望这将有助于。 :) :) :)