In this video we are going to learn about the HTTP Request and Form.
Occasionally developers may need to fetch an instance of the ongoing HTTP request.
In Laravel 8, we can obtain so by using Request class in our controller.
This will automatically fetch the incoming HTTP request instance.
So lets see some usages of HttpRequest for that just open user controller.
You can notice that Illuminate\\Http\\Request is already attached to all the controllers that we create with artisan command.
Now we can use this Request Class inside our controller method.
So I am just going to type here Request $request.
now we can use the $request object here.
for accessing their methods.
So just inside the index method add the following code.


public function index(Request $request)
{
return $request->method();
}


Now save the file.
and check it on the browser.
So switch to the browser.
Add here /users and press enter.
Now you can see here the requested method, which is get, is showing here.
nNow see the Request path method.
Path method returns the request's path information.
So add here.



public function index(Request $request)
{
return $request->path();
}


So, if the incoming request is targeted at http://localhost:8000/users, the path method will return users.
So lets check, switch to the browser and refresh the page now you can see here.
It shows users.
Which is url path.
Now Another Request method is URL.
Which is used to retrieve the url, from the incoming request.
So lets see the url method.


public function index(Request $request)
{
return $request->url();
}


Now save and switch to the browser and refresh the page.
Now you can see the url which is localhost:8000/users.
If I add some query string in the url.
lets say ?name=jenifer&age=25.
Now enter, You can see here query string is not showing here.
So for showing the complete url with the query string.
Then use fullUrl() method so just goto the controller and add here fullUrl()

public function index(Request $request)
{
return $request->fullUrl();
}

Now save it and switch to browser.
An refresh the page.
Ok now you can see here.
It shows full url with query string.
Alright now we are going to see how can we use Form in laravel 8.
For sending a request to server.
Lets create a controller first Switch to the command prompt and run the following command.


php artisan make:controller LoginController


Open login controller and create method.

public function index()
{
return view('login');
}


Now create this view so go inside the resources/views directory and here lets create login.blade.php view file.
And also create rotue for this view so go to the web.php file and create the route.


Route::get('/login',[LoginController::class,'index');

No go to the login.blade.php file and here first of all add html5 boilerplate.
So type Html:5 and press tab.
Now add the title here login.
and inside the body just add the form.
Before adding the form for the styling the page.
I am just going to add bootsrap 4 cdn.
So for that goto the getbootstrap.com Then click on getting started.
and from here just copy this css.
and put inside the head tag.
Now copy the js.
and put just before the closing body tag.
Ok now bootstarp 4 added in our project No we can use the bootstrap 4 class.
So just add section then a container and row and create column.


<div class=\"container\">
<div class=\"row\">
<div class=\"col-md-6 offset-md-3\">
<div class=\"card\">
<div class=\"card-heading\">
Login
</div>
<div class=\"card-body\">
<form method=\"POST\" action=\"{{route('login.submit')}}\">
@csrf
<div class=\"form-group\">
<label for=\"email\">Email address</label>
<input type=\"email\" class=\"form-control\" name=\"email\" />
</div>
<div class=\"form-group\">
<label for=\"password\">Password</label>
<input type=\"password\" class=\"form-control\" name=\"password\" />
</div>
<button type=\"submit\" class=\"btn btn-primary\">Submit</button>
</form>
</div>
</div>
</div>
</div>
</div>



Now go to the login controller.
Here create a method for loginsubmit.
Now create a route for the form submittion.


public function loginsubmit()
{
return \"Form Submitted\";
}


Now create a route for this function.
So go to the web.php file and write here.

Route::post('/login',[LoginController::class,'loginsubmit')->name('loginsubmit');

Go to the browser and just type here /login.
and fill some data here and now click on submit.
Now you can see form is now submitted You may also retrieve all of the input data as an array using the all method:.
For that just add the following code in loginsubmit method.

public function loginsubmit()
{
$input = $request->all();
return $input;
}

Now re-submit the form so fill again some data and now submit.
You can see here the email and password which was submitted ok You can also get individual request input.
By using the request input method.
So for that in loginsubmit method write the following code.

public function loginsubmit()
{
$name = $request->input(email');
$password= $request->input(pasword');
return array('Your Email: '=>$email,'Password'=>$password);
}


Now re-submit the form and you can see the email and password here.
So in this way you can grab the input data from the request.