LoginSignup
7
10

More than 5 years have passed since last update.

テンプレート内でquerystring付きのURLを生成するには?

Posted at

routes.php内では以下の用に定義しておいて

Route::get('example', array('as' => 'example.index', 'uses' => 'ExampleController@getIndex'));

テンプレートでは以下の用に記述する

{{ URL::route('example.index', array('key' => 'value')) }}

コントローラに直接渡したい場合は、

{{ URL::to(action('ExampleController@anySearch') . '?' . http_build_query(array('key'=>'value'))) }}

以下のようなURLが生成される

http://localhost:8000/example/search?key=value
7
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
10