I'm creating a Laravel 4 webapp and got the following route:
Route::get('products/{whateverId}', 'ProductController@index');
This is my index-function in ProductController:
public function index($whateverId)
{
$products = Product::all();
$data['whateverId'] = $whateverId;
return View::make('products', compact('products'), $data);
}
In my view, this returns the following error:
<p>Product: {{ $data['product'] }}</p>
ErrorException Undefined variable: data (View: /Users/myuser/webapp/app/views/products.blade.php)