skip to Main Content

When I add this code to my blade. It displays and shows an array.

[‘2600000’] [‘4500000’]
@foreach($amazings as $product)
    {{ number_format($product->prices->pluck('value')) }}
@endforeach

2

Answers


  1. make the value $num float then pass that to that function.
    Use floatval($num)
    See documentation https://www.php.net/manual/en/function.floatval.php

    Login or Signup to reply.
  2. Pluck will still return a collection. You’d need to iterate through it, either with another foreach loop, or such as through map, etc:

    @foreach($amazings as $product)
        @foreach($product->prices->pluck('value')->all() as $val)
            {{ number_format($val) }}
        @endforeach
    @endforeach
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search