0
我有一个方法(客户)的函数:Laravel 5.2 - 阵列没有传递
public function getAll() {
$values = DB::table('customers')->orderBy('company','asc')->where('company','<>','')->get();
return $values;
}
这是从一个路线叫:
Route::get('/customers', function(){
$cust = new \App\Customer();
$customers = $cust->getAll();
//dd($customers);
return view('customers.index')->with(compact('customers'));
});
如果我使用dd检查,我得到一个客户阵列。
在视图中我有
@foreach($customers as $item)
<tr>
<td>{{ $item->customer }}</td>
<td>{{ $item->address }}</td>
<td>{{ $item->city }}</td>
<td>{{ $item->postcode }}</td>
</tr>
@endforeach
但我正在逐渐
Undefined property: stdClass::$customer
帮助!我已经尝试了一切......
我改变了路线线路的建议,但我仍然有完全相同的错误 - 未定义的属性:stdClass的:: $客户 – Jim