Can I have a variable number of URI parameters or key-value pairs in Laravel 4?

非 Y 不嫁゛ 提交于 2019-12-01 22:02:40

You should use the query string (GET parameters) for filters like those. When you use the query string parameters can be in any order and can be easily skipped if they're not needed. It's also very easy to make a simple form (with method="GET") that can filter your list

With GET parameters a URL would look more like:

/products
/products?sort=alphabetically
/products?filter=cloths
/products?socks=true
/products?sort=alphabetically&socks=true&hats=false

GET parameters can then be retrieved individually with Input::get('name', 'default') or as a collection with Input::all(). This is also how the paginator will add the page number to your links.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!