2016-06-14 88 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已經使用刀片如果

希望這將有助於。 :) :) :)