Why I'm getting htmlenties() error

Posted 2 years ago by Khudadad

I'm trying to display sum of a column but getting this error:

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

This is my code in the controller:

    $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 the View:

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

any help.

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.