我是一个laravel初学者。我想从表单中获取输入的信息。表单字段名称为name
、email
和contact.
,我正试图像核心php 中的$_POST['name'] ,$_POST['email']
一样获取这些名称
{{form::open(array('route'=>'employees.store'))}}
controller store()函数:这将从表单中获取所有输入。我想要单独的输入。
public function store()
{
$input=Input::all();
employee::create($input)
}
public function store()
{
$input = Input::all();
$e = new Employee();
$e->name = $input['name'];
$e->email = $input['email'];
$e->contact = $input['contact'];
...
$e->save();
}
但是store()
不应该接收这样的Request对象吗?
public function store(Request $request)
然后你可以做这个
public function store(Request $request)
{
$input = $request->all();
$e = new Employee();
$e->name = $input['name'];
$e->email = $input['email'];
$e->contact = $input['contact'];
...
$e->save();
}