2016-05-10 7 views
1

私はラベールの草分けです。私はフォームから入力された情報を取得したい。これは、フォームからのすべての入力を取得します:フォームのフィールド名は、私はちょうどコアPHPの$_POST['name'] ,$_POST['email']フォームからの個々の入力を取得するlaravel

{{form::open(array('route'=>'employees.store'))}} 

のようなコントローラ店()関数を取得しようとしていますnameemailcontact.です。私は個々の入力が欲しい。

public function store() 
{ 
    $input=Input::all(); 
    employee::create($input) 
} 

答えて

0
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(); 
} 
を行うことができます
関連する問題