Reputation: 29
Here is the Migration file, I have stored two numbers as json in mysql database, ["1234","4568"]. like this the O/P I am getting is "[\"1234\", \"5678\"]" but I need to print 1234,5678
public function up()
{
Schema::create('store', function (Blueprint $table) {
$table->increments('id');
$table->json('store_numbers');
});
}
//blade view
@foreach($stores as $store)
<tr>
<td>{{ $store->store_id }}</td>
<td>{{ json_encode($store->store_numbers)}}</td>
</tr>
@endforeach
Upvotes: 1
Views: 159
Reputation: 491
Try this:
@foreach($stores as $store)
<tr>
<td>{{ $store->store_id }}</td>
@php $store_numbers= json_decode($store->store_numbers); @endphp
@foreach($store_numbers as $store_number)
<td>
{{$store_number}}
</td>
@endforeach
</tr>
@endforeach
Upvotes: 1