Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Laravel 4中使用URL参数进行过滤?_Url_Laravel_Filter_Laravel 4 - Fatal编程技术网

如何在Laravel 4中使用URL参数进行过滤?

如何在Laravel 4中使用URL参数进行过滤?,url,laravel,filter,laravel-4,Url,Laravel,Filter,Laravel 4,假设我正在对项目列表进行分页,并希望按第一个字母对其进行筛选,我的URL类似于myURL.com/items?sortBy=C&page=2,这将返回以C开头的项目的第2页(分页已经开始工作) 我的问题是,如何检索sortBy=C?以及路由.php和控制器的外观如何?您只需使用输入::get(),它会考虑查询字符串 因此,在控制器中: $letter = Input::get('sortBy'); 您不必担心路由或控制器(我的意思是,您不必传递额外的变量或检查段) 例如: Route::get

假设我正在对项目列表进行分页,并希望按第一个字母对其进行筛选,我的URL类似于
myURL.com/items?sortBy=C&page=2
,这将返回以C开头的项目的第2页(分页已经开始工作)


我的问题是,如何检索
sortBy=C
?以及
路由.php
和控制器的外观如何?

您只需使用
输入::get()
,它会考虑查询字符串

因此,在控制器中:

$letter = Input::get('sortBy');
您不必担心路由或控制器(我的意思是,您不必传递额外的变量或检查段)

例如:

Route::get('items', array('as' => 'items', 'uses' => 'ItemsControllers@items'));

function items()
{
  $sort = Input::get('sortBy');

  // OR, if you want, you can check first for the index:
  if (Input::has('sortBy')) {
   $sort = Input::get('sortBy');
  }
}

您只需使用
输入::get()
,它会考虑查询字符串

因此,在控制器中:

$letter = Input::get('sortBy');
您不必担心路由或控制器(我的意思是,您不必传递额外的变量或检查段)

例如:

Route::get('items', array('as' => 'items', 'uses' => 'ItemsControllers@items'));

function items()
{
  $sort = Input::get('sortBy');

  // OR, if you want, you can check first for the index:
  if (Input::has('sortBy')) {
   $sort = Input::get('sortBy');
  }
}

您只需使用
输入::get()
,它会考虑查询字符串

因此,在控制器中:

$letter = Input::get('sortBy');
您不必担心路由或控制器(我的意思是,您不必传递额外的变量或检查段)

例如:

Route::get('items', array('as' => 'items', 'uses' => 'ItemsControllers@items'));

function items()
{
  $sort = Input::get('sortBy');

  // OR, if you want, you can check first for the index:
  if (Input::has('sortBy')) {
   $sort = Input::get('sortBy');
  }
}

您只需使用
输入::get()
,它会考虑查询字符串

因此,在控制器中:

$letter = Input::get('sortBy');
您不必担心路由或控制器(我的意思是,您不必传递额外的变量或检查段)

例如:

Route::get('items', array('as' => 'items', 'uses' => 'ItemsControllers@items'));

function items()
{
  $sort = Input::get('sortBy');

  // OR, if you want, you can check first for the index:
  if (Input::has('sortBy')) {
   $sort = Input::get('sortBy');
  }
}

哦,哇,我不知道Input::get()是这样工作的,我想它只适用于表单内部的输入,谢谢!哦,哇,我不知道Input::get()是这样工作的,我想它只适用于表单内部的输入,谢谢!哦,哇,我不知道Input::get()是这样工作的,我想它只适用于表单内部的输入,谢谢!哦,哇,我不知道Input::get()是这样工作的,我想它只适用于表单内部的输入,谢谢!