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
Method to check if current request is a POST request. #1517
Conversation
This is much more useful than using Request::method() when updating models. If the request is a POST request, update your model with the input, otherwise render to response.
{ | ||
$method = static::foundation()->getMethod(); | ||
|
||
return ($method == 'POST') ? true : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just return $method == 'POST'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fast haha
I don't really agree with this... There's no much use for checking if the method is a specific one. And if this method is added then must be added |
It makes life a little easier with these methods.
|
I think you should use RESTful controllers. Use different methods to separate the logic in your code. |
I feel these should only be used if your intentions are to use all of the RESTful methods. You could also get some code duplication by being restricted to using a RESTful controller. |
Also, read about POST-redirect-GET. |
This is how I have always written my applications in Laravel (with POST-redirect-GET) and I do see how without it there could be issues. |
This is much more useful than using Request::method() when updating models. If the request is a POST request, update your model with the input, otherwise render to response.