I want to use interface methods like request to get HTML data. If anyone knows please explain.
I want to get output like this! Please help in writing a sample Request php interface.
My real scenario is that I have a controller that has a create function. The create function passes parameters as Request class. I want to access the HTML input as I mentioned in the question. This is my problem.
<input name="inputname"> <input name="anotherinputname">
public function create(Request $request) { echo $request->inputname; echo $request->anotherinputname; }
So please help make the Request class. Thanks
P粉9856865572024-03-31 10:54:21
It doesn't work like you think. Laravel uses dependency injection. You can define a Request class and map POST data to properties in its constructor. Something like this:
class Request { public $get; public $post; public function __construct() { $this->get = $_GET; $this->post = $_POST; } }
You can then access the POST data via:
$request->post['anotherinputname'];