lara_net
1611
15
Laravel

Display json from database to view

Posted 1 year ago by lara_net

I have a column that stores json data as ["Item_1", "Item_2", "Item_3"]. It has only one field - Items.

How can I display the json data on my blade view?

My Controller

public function show(Request $request, $id)
{
$items= Item::findorfail($id);
return view('display', compact('items'));
}

View Blade

@foreach($items as $item)
 {{ json_decode($item) }}
@endforeach

It gives error:

htmlspecialchars() expects parameter 1 to be string, array given

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