Answer the question
In order to leave comments, you need to log in
How to display a record in json format?
There is an entry in the database in JSON format
Trying to Display in a loop
@foreach($products as $item)
<p>{{ $item->product_id }}</p>
<p>{{ $item->value->price }}</p>
@endforeach
Answer the question
In order to leave comments, you need to log in
In general, single quotes are not allowed in json. There will be an error. Perhaps the cast suppresses decoding errors and you do not see them, and the output after the cast is null due to an error.
Try changing the single quotes in the base to double quotes.
Also, if the database version allows, you can use the JSON type for the field
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question