Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if request is GET or POST

In my controller/action:

if(!empty($_POST)) {     if(Auth::attempt(Input::get('data')))     {         return Redirect::intended();     }     else     {         Session::flash('error_message','');     } } 

Is there a method in Laravel to check if the request is POST or GET?

like image 731
JoeLoco Avatar asked Jan 11 '14 16:01

JoeLoco


People also ask

What is if request method == POST?

The result of request. method == "POST" is a boolean value - True if the current request from a user was performed using the HTTP "POST" method, of False otherwise (usually that means HTTP "GET", but there are also other methods).


1 Answers

According to Laravels docs, there's a Request method to check it, so you could just do:

$method = Request::method(); 

or

if (Request::isMethod('post')) { //  } 
like image 108
Tom Avatar answered Sep 20 '22 05:09

Tom