Get form input value in Laravel 5
Get form input value in Laravel 5 Accessing Request – If you are using the laravel 5 version, so this tutorial will be very helpful for you. In this tutorial I will help to get form input value in your controller page. You need to set the Illuminate\Http\Request; in your controller page below the namespace App\Http\Controllers;.
This is the request accessing in laravel 5 version. The request is accessing to obtain an instance of the current HTTP request via dependency injection. So the incoming request instance will automatically be injected by the service container.
Now go to the controller page and set request in the function name and create a request variable. That’s like:
Request $request
I have a example for you, so follow the code in the below:
Example:
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class UserController extends Controller { public function store(Request $request) { $name = $request->input('name'); } }
If you want to store input values in an array variable in laravel 5. So you can do it, that’s like:
$data=array(‘name’=>$name);