有人可以告诉我为什么会收到此错误:
“未定义的变量:列表(查看:\ app \ views \ pages \ listings.blade.php)”
控制器
class ListingsController extends BaseController {
public function showListings() {
$listings = Listing::paginate(10);
return View::make('pages.listings', $listings);
}
}
查看
<div class="container">
<div id="main">
<div class="row">
<div class="span9">
<h1 class="page-header">Listings</h1>
@foreach($listings as $listing)
{{ $listing->address }}
@endforeach
</div>
</div>
</div>
</div>
@include('includes.footer')
答案 0 :(得分:4)
尝试这样做:
return View::make('pages.listings')->with('listings', $listings);
或
return View::make('pages.listings', array('listings' => $listings));
甚至
return View::make('pages.listings', compact('listings'));