How to Get Request Method in Laravel?

By Hardik Savani April 28, 2022 Category : Laravel

This article goes in detail on how to get request method in laravel. this example will help you laravel get the request method. I would like to show you get request method in laravel. let’s discuss laravel get request method get. Follow bellow tutorial step of post.

Here, I will give 3 ways to get the request method in laravel 6, laravel 7, laravel 8 and laravel 9 application.

Example 1:

$requestMethod = request()->method();

dd($requestMethod);

Example 2:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller

{

/**

* Display a listing of the resource.

*

* @return \Illuminate\Http\Response

*/

public function index(Request $request)

{

$requestMethod = $request->method();

dd($requestMethod);

}

}

Example 3:

$requestMethod = \Request::method();

dd($requestMethod);

Output will be "GET", "POST", "PUT" or "DELETE" method.

i hope it can help you...

Tags :