My Laravel controller class which checks if the email is already stored in the database or not: In my User table, it checks for if email exists in the database or not?

```
public function checkemail(){
      $userCount = DB::table('users')->where('email', input::get('email'));
      if($userCount->count()) 
      {
          return Response::json(array('msg' => 'true'));
      }
      else 
      {
       return Response::json(array('msg' => 'true'));
      }
}

```

My Ajax method which checks if email is already stored in database or not?
If it is stored in database then it should say email address already taken or else nothing. If email is taken, it shows in red line and if not then nothing.
The form name is registration.  

url in web.php is 

```
routes::post('checkmail','postcontroller@checkmail');

```

**jQuery**

```
$("#registration").validate({

    errorElement: 'div',
    errorLabelContainer: '.errorTxt',
    ignore: [],

    //following rules for email
    rules: {
        email: {
            required: true,
            email: true,
            remote: {

                url: "checkemail",
                type: "post",
                data: {
                    email: $("input[email='email']").val()
                },
                dataFilter: function(data) {
                    var json = JSON.parse(data);
                    if (json.msg == "true") {
                        return "\"" + "Email address already in use" + "\"";
                    } else {
                        return 'true';
                    }
                }
            }
        },

    },
    messages: {
        email: {
            required: 'Email is required',
            email: 'Please enter a valid email address',
            remote: 'Email already taken'
        }

    },

    errorPlacement: function(error, element) {
        if (element.attr("name") == "email") {
            $(".erroremail").append(error);
        } else {
            error.append($('.errorTxt span'));
        }
    },

    submitHandler: function(form) {
        form.submit();

    }

});

```

Can anyone help me please, I am quite new to Laravel and ajax as a whole.