Check if request is GET or POST

I've solve my problem like below in laravel version: 7+

In routes/web.php:

Route::post('url', YourController@yourMethod);

In app/Http/Controllers:

public function yourMethod(Request $request) {
    switch ($request->method()) {
        case 'POST':
            // do anything in 'post request';
            break;

        case 'GET':
            // do anything in 'get request';
            break;

        default:
            // invalid request
            break;
    }
}

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'))
{
// 
}

The solutions above are outdated.

As per Laravel documentation:

$method = $request->method();

if ($request->isMethod('post')) {
    //
}