How do I pass a hard coded variable to a controller?
My route is:
Route::group(array('prefix' => $locale), function() {
Route::get('/milk', array('as' => 'milk', 'uses' => 'ProductsController@index'));
});
我想做一些事情,比如:
Route::get('/milk', array('as' => 'milk', 'uses' => 'ProductsController@index(1)'));
但那不管用.
How can this be done?
如果我没有解释清楚,很抱歉.
I wish to simply hardcode (set in stone by me) the type_id for certain routes like so:
Route::get('/milk', array('as' => 'milk', 'uses' => 'ProductsController@index(1)'));
Route::get('/cheese', array('as' => 'cheese', 'uses' => 'ProductsController@index(2)'));
...
我的ProductsController供参考:
class ProductsController extends BaseController {
public function index($type_id) {
$Products = new Products;
$products = $Products->where('type_id', $type_id)->get();
return View::make('products.products', array('products' => $products));
}
}