1

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

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.