2013-11-28 68 views
1

我在Laravel 4中完成了以下查詢,我需要知道如何輸出結果作爲每個值的列表。這裏是查詢和它的結果。Laravel Blade查看輸出循環

//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

如果你使用刀片模板(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 
+0

非常感謝你:)。欣賞解決方案和提示。 –