Khodadad
Khodadad

Reputation: 126

How to sole htmlentities() error in Laravel

I'm trying to display sum of some columns in laravel using query builder but getting this error:

htmlentities() expects parameter 1 to be string, object given

This is the query:

$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();

And view:

<div class="col-xs-8">
      <p class="text-elg text-strong mb-0">
          {{ number_format($purchase->usd_total,2) }}
       </p>
           <span>Purchases</span>
 </div>

Upvotes: 0

Views: 45

Answers (1)

user4578154
user4578154

Reputation:

dd($purchase->usd_total) an you will find the reason.

Upvotes: 1

Related Questions