Laravel和Jquery验证:如何检查电子邮件是否存在

Good night everone !

I am using jquery validation plugin and I have a question to check if email existes.

I have this on JS

 email: {
          required: true,
          email: true,
          remote: {
          url: "comprobarEmail",
          type: "get",            
      }
        },

I receive the following error in PHP

in_array() expects at least 2 parameters, 1 given

My PHP code

public function checkEmail()
{
    $user = User::all()->lists('email');
    if (in_array(Input::get('email'), $user)) {
        return Response::json(Input::get('email').' is already taken');
    } else {
        return Response::json(Input::get('email').' Username is available');
    }
}

You don't need to fetch the full list of emails – you could check if email exists directly in your query (powered by Eloquent ORM):

public function checkEmail()
{
    $user = User::all()->where('email', Input::get('email'))->first();
    if ($user) {
        return Response::json(Input::get('email').' is already taken');
    } else {
        return Response::json(Input::get('email').' Username is available');
    }
}