doulang7699
2018-06-08 11:56
浏览 58
已采纳

无法将laravel数组传递给视图

I have an array that i want to return from the controller to the view.But unable to retrieve that. If i dump my array it looks like this:

array:121 [▼
  0 => array:10 [▼
    "ProcedureName" => "eye"
    "Status" => "referred"
    "PreferredDate" => "12/12/2018"
    "PreferredCity" => "Bangalore"
    "BookingId" => "EZBK000126"
    "Documents" => ""
    "Name" => "vik kon"
    "Age" => 62
    "Gender" => "male"
    "Mob" => "1110002223"
  ]
  1 => array:10 [▼
    "ProcedureName" => "eye"
    "Status" => "referred"
    "PreferredDate" => "12/12/2018"
    "PreferredCity" => "mysore"
    "BookingId" => "EZBK000125"
    "Documents" => ""
    "Name" => "vik kon"
    "Age" => 62
    "Gender" => "male"
    "Mob" => "9146178526"
  ]

So i want to get it to show inside my view .Currently my code looks like this :

@foreach($new_records as $new_recordss)

    <tr>

      <td scope="col">{{ $new_recordss->ProcedureName }}</td>

      <td scope="col">{{ $new_recordss->Status }}</td>

      <td scope="col">{{ $new_recordss->Age }}</td>

      <td scope="col"><div class="btn-group">

   </div>
 </td>


    </tr>
    @endforeach

But this gives the following error:

Trying to get property of non-object

图片转代码服务由CSDN问答提供 功能建议

我有一个数组,我想从控制器返回到view.But无法检索它。 如果 我转储我的数组看起来像这样:</ p>

  array:121 [▼
 0 =&gt;  array:10 [▼
“ProcedureName”=&gt;  “眼睛”
“状态”=&gt;  “refer”
“PreferredDate”=&gt;  “12/12/2018”
“PreferredCity”=&gt;  “班加罗尔”
“BookingId”=&gt;  “EZBK000126”
“Documents”=&gt;  “”
“名称”=&gt;  “vik kon”
“Age”=&gt;  62 
“性别”=&gt;  “男性”
“Mob”=&gt;  “1110002223”
] 
 1 =&gt;  array:10 [▼
“ProcedureName”=&gt;  “眼睛”
“状态”=&gt;  “refer”
“PreferredDate”=&gt;  “12/12/2018”
“PreferredCity”=&gt;  “mysore”
“BookingId”=&gt;  “EZBK000125”
“Documents”=&gt;  “”
“名称”=&gt;  “vik kon”
“Age”=&gt;  62 
“性别”=&gt;  “男性”
“Mob”=&gt;  “9146178526”
] 
 </ code> </ pre> 
 
 

所以我想让它在我的视图中显示。目前我的代码看起来像这样:</ p>

  @foreach($ new_records as $ new_recordss)
 
&lt; tr&gt; 
 
&lt; td scope =“col”&gt; {{$ new_recordss-&gt; ProcedureName}}&lt; /  td&gt; 
 
&lt; td scope =“col”&gt; {{$ new_recordss-&gt; Status}}&lt; / td&gt; 
 
&lt; td scope =“col”&gt; {{$ new_recordss-  &gt;年龄}}&lt; / td&gt; 
 
&lt; td scope =“col”&gt;&lt; div class =“btn-group”&gt; 
 
&lt; / div&gt; 
&lt; /  td&gt; 
 
 
&lt; / tr&gt; 
 @endforeach 
 </ code> </ pre> 
 
 

但是这会出现以下错误:</ p> < blockquote>

尝试获取非对象的属性</ p> </ blockquote> </ div>

2条回答 默认 最新

相关推荐 更多相似问题