Why I'm getting htmlenties() error

Published 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')

And the View:

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

any help.


dd($purchase->usd_total) and you will see that it is object and not attribute.


When dd($purchase->usd_total) the result is :


can u show me your entire blade file ?

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

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