Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paramGet and paramPost #283

Open
jk3us opened this issue Mar 19, 2015 · 1 comment
Open

paramGet and paramPost #283

jk3us opened this issue Mar 19, 2015 · 1 comment
Assignees

Comments

@jk3us
Copy link

jk3us commented Mar 19, 2015

I feel like there should be a way to get a single value from either get or post explicitly. paramsGet() gives you the whole collection for get, and param() will give you a single value, but may not be the one you were looking for if there happens to be a get and post variable with the same name. So, right now, I'm just doing $post = $request->paramsPost()->all(); at the top and using $post just like $_POST, just somewhat less global.

If it could also somehow encapsulate/simplify php's filter_input* functionality, that could be pretty awesome. http://php.net/manual/en/function.filter-input-array.php

@Rican7 Rican7 self-assigned this Mar 24, 2015
@Rican7
Copy link
Member

Rican7 commented Mar 25, 2015

There really kind of is. :)

The $request->param() and $request->params() methods are just convenience methods that merge together all of the possible parameter locations. As you said, the paramsGet() method gives you the entire collection object, but then you still get the very convenient API. Calling $request->paramsGet()->all() returns a raw PHP array (not very friendly to use), which essentially defeats the purpose of the collections all together. Instead use the collections as they're given to you:

$params = $request->paramsPost();

$time_zone = new DateTimeZone($params->get('time_zone'));
$date = new DateTime($params->get('date'), $time_zone);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants