I would like to get html data using interfaced method like a Request. If anyone know please explain me.
I would like to get output like this one! please help to write sample Request php interface.
public function create(Request $request) {
echo $request->inputname;
echo $request->anotherinputname;
}
CodePudding user response:
It's not working as you think. Laravel uses dependency injection. You can define a Request class and in its constructor, you can map the POST data to properties. something like this:
class Request {
public $get;
public $post;
public function __construct() {
$this->get = $_GET;
$this->post = $_POST;
}
}
and then you can access the POST data this way:
$request->post['anotherinputname'];
CodePudding user response:
Assuming you have this method in your controller:
public function create(Request $request) {
You should grab your variables by doing:
$field = $request->get('fieldName');
dump($field);