How to Get Request Method in Laravel?

By Hardik Savani April 16, 2024 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, laravel 9, laravel 10 and laravel 11 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 :
Shares