从形式laravel获取个人输入

时间:2016-05-10 03:32:47

标签: php laravel-5

我是一个laravel的乞丐。我想获取表格中输入的信息。表单字段名称为nameemailcontact.,我试图像核心php中的$_POST['name'] ,$_POST['email']一样获取

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

controller store()函数:这将从表单中获取所有输入。我想要个人投入。

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

1 个答案:

答案 0 :(得分:0)

store()

但是public function store(Request $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();
}

然后你可以这样做

void replaceSpace(char *s) {
    int spaces = 0;
    for (int i = 0; i < strlen(s); i++) {
        if (s[i] == ' ') {
            spaces++;
        }
    }

    // new string that includes overwriting space, and two additional chars
    int newLen = strlen(s) + spaces * 2;

    s[newLen] = '\0';
    for (int i = strlen(s) - 1; i >= 0; i--) {
        if (s[i] == ' ') {
            s[newLen - 1] = '0';
            s[newLen - 2] = '2';
            s[newLen - 3] = '%';
            newLen -= 3;
        }
        else {
            s[newLen - 1] = s[i];
            --newLen;
        }
    }
}




char test[] = "rep lace Spac e";
replaceSpace(test);
cout << test << endl; //rep%20lace%20Spac%20e