【发布时间】:2014-05-12 21:44:55
【问题描述】:
我正在创建一个 Laravel 4 webapp 并获得以下路线:
Route::get('products/{whateverId}', 'ProductController@index');
这是我在 ProductController 中的索引函数:
public function index($whateverId)
{
$products = Product::all();
$data['whateverId'] = $whateverId;
return View::make('products', compact('products'), $data);
}
在我看来,这会返回以下错误:
<p>Product: {{ $data['product'] }}</p>
错误异常 未定义变量:数据(查看:/Users/myuser/webapp/app/views/products.blade.php)
【问题讨论】: