2016-06-14 7 views
0

誰もが。でlaravelでこのクエリを実行すると、私が欠けているものを任意の助けを知らないとき、私は以下のエラーでLaravelでhtmlentities()例外を処理する方法

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

に直面しています。 感謝 クエリ:

$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 

はこれが役立つことを願っていた場合 too.Iはブレードを使用している場合は、PHPを使用することができますもちろんの

。 :) :) :)

関連する問題