I have this in the backend
return view('changePrice')->with('list',$list);
And my page has
<!DOCTYPE html>
<html>
<head>
</head>
<body>
{!! json_encode($list) !!}
</body>
</html>
And I can see on my page something like
[{"id":"10e408ab-b768-6c84-9793-588a440e8b71","name":"Cambio Precio","lista":"OVG","oficina_ventas":"1300","lista_precios":"14","tipo_precio":"LISTA","nit":"","producto":"209","material":"LANGOSTINO 16-20","unidad_medida":"KG","precio_actual":"62900.000000","nuevo_precio":"67300.000000","fecha_inicio":"2017-01-16","procesado":"0"},,{"id":"111b95da-bde7-3c2f-0a92-588a44f6022f","name":"Cambio Precio","lista":"OVG","oficina_ventas":"1100","lista_precios":"17","tipo_precio":"LISTA","nit":"","producto":"274","material":"CAMARON GOLDEN CRUDO - RAW PD 51-60","unidad_medida":"KG","precio_actual":"36500.000000","nuevo_precio":"37500.000000","fecha_inicio":"2017-01-16","procesado":"0"}
I do not know much about blade, but,How to tap this json?To create a table
If you want to show all data then you can get easily in view page.
{{print_r($list)}}
Otherwise you can use @foreach
Please see example here.
<table>
@foreach($list as $value)
<tr>
<td>{{ $value->id }}</td>
<td>{{ $value->name }}</td>
</tr>
@endforeach
There's no need to turn a perfectly good array/collection into JSON here. Just work on the PHP $list
directly, using a @foreach
loop in Blade:
<table>
@foreach($list as $item)
<tr>
<td>{{ $item->id }}</td>
<td>{{ $item->name }}</td>
</tr>
@endforeach
</table>
I'd strongly encourage you to consult the Blade documentation for more examples of this sort of thing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.