Laravel What Is Http Request?

What Is Http Request?

The Http requests are created for the use to access the some server request it is hosted on the server. For example when a use visit any dynamic site he download, submit or edit some data, these data fetch or submit by Http requests. there are six method of Http Request and these are follow.

How to Create Middleware In Laravel?

  1. Get Method
  2. Post Method
  3. Put Method
  4. Delete Method
  5. Head Method
  6. Patch Method
What Is Http Request
What Is Http Request

Laravel Get Method:

In get method the use get the input data by Http request from the server or Html form. Creating the get method in Laravel you need to make one view and one controller.

Make Controller In Laravel:

php artisan make:controller SignupController

Create Function In SignupController

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class usersignup extends Controller
{
    //
    function testRequest(Request $req){

    	return $req->input();
    }
}

Use the SignupController

use App\Http\Controllers\SignupController;

Create Html View to Get The Data

Go to the view directory and creaate a view usersignup.blade.php and past the following code.

@include('inner')
<h1 style="text-align: center;">User Signup Page</h1>
<div class="form-group">
	
	<form action="usersignup" method="Get">
		@csrf
		{{@method_field('put')}}
	<input type="text" class="form-control" name="username" placeholder="Enter Usernme"><br>
	<span style="color: red;">@error ('username'){{$message}} @enderror</span>
	
	<input type="password" class="form-control" name="password" placeholder="Enter Password"><br>
	<span style="color: red;">@error ('password'){{$message}} @enderror</span>
	<br><br>
	<button class="btn btn-primary">Submit</button>
	</form>
</div>

Create Route For

Route::put("signup",[usersignup::class, 'testRequest']);

This Post Has One Comment

Leave a Reply