我在Laravel 4中完成了以下查询,我需要知道如何将结果作为每个值的列表输出。这是查询及其结果。
//List all the buyers
$buyers = DB::table('requests')->get();
$data = array();
//Buyers Object
$data['requests']= $buyers;
return View::make('buyers.index',compact($data));
这是结果。
{"requests":[
{"id":1,"person":1000,"shoe":"nike","shoes":5,"money":250,"pay method":"paypal","Text":"blobs osf text","good":1:},
{"id":2,"person":1002,"shoe":"adidas","shoesy":1,"money":100,"pay method":"moneytransfer","Text":"looking to pick up some BIT. Hit me up and trade with me I am pretty competitive. We can work out something so we both get profits. one.","good":1}
]}
答案 0 :(得分:0)
如果您使用刀片模板(http://laravel.com/docs/templates)
@foreach ($requests as $request)
<h2>Request {{ $request['id'] }}</h2>
<ul>
@foreach ($request as $field => $value)
<li>{{ $field }}: {{ $value }}</li>
@endforeach
</ul>
@endforeach