PendejoTrax
PendejoTrax

Reputation: 170

Laravel Array to View

My collection looks like this

array:3 [▼
  "label" => array:2 [▼
    0 => "onhold"
    1 => "approved"
  ]
  "data" => array:2 [▼
    0 => 1
    1 => 1
  ]
  "chart_data" => "{"label":["onhold","approved"],"data":[1,1]}"
]

I would like to pass chart_data to my blade VIEW. It should show something like this

Onhold 1 Approved 1

I tried the following to no luck

  @foreach ($data as $datum)
  {{$datum['label']}}
  {{$datum['data']}}
  @endforeach

Would appreciate any help. Thanks!

Upvotes: 0

Views: 58

Answers (1)

SEYED BABAK ASHRAFI
SEYED BABAK ASHRAFI

Reputation: 4271

You can use @for in your blade

@for($i=0;$i<count($data);$i++)
    {{$datum['label'][$i]}}
    {{$datum['data'][$i]}}
@endfor

Upvotes: 1

Related Questions