数组到字符串的转换电子邮件唯一验证Laravel

时间:2018-07-10 12:51:13

标签: laravel validation

嗨,有人可以帮我吗,我必须使我以这种方式尝试过的电子邮件保持唯一性。

    public function sendform(MenteesFormRequest $request){
 $email = $this->validate($request, [
        'email' => [
            'required',
            'email',
            Rule::unique('users'),
    ]]);



        $mentees = User::create([
            'first_name' => $request['first_name'],
            'last_name'  => $request['last_name'],
            'email'      => $email,
            'user_group'       => 3,
             'remember_token'   => str_random(40)
        ]);


         return redirect()->back();

    }

它显示了很好的验证,但是当我尝试提交此验证时,它给了我这个错误:

"Array to string conversion"

1 个答案:

答案 0 :(得分:0)

因为您的$ email是数组,所以要这样做:

False