odbhut.shei.chhele
odbhut.shei.chhele

Reputation: 6234

Laravel 4 validation says column not found

This is my first time using Laravel 4. I am sending some input. There is an email in the input. I am trying to check whether that already exists or not. If it does than it should send some error. But it is saying there is no such column in my table.

Here is my code:

$rules = array(
        'email' => array('required', 'email', 'unique:users, user_email'),
        'password' => array('required', 'min:7', 'unique:users, user_password')
    );
 $validation = Validator::make(Input::all(), $rules);
  if($validation->fails())
{
   $messages = $validation->messages();

    dd($messages);
}

My table name is users and column name is user_email and user_password. The name of the input field is email.

Upvotes: 1

Views: 422

Answers (1)

Daedalus
Daedalus

Reputation: 7722

Reading through the documentation for validation rules, I do not see any spacing between column names, and the column info. It may be that spaces are not stripped from the data, and this would probably be the cause of your error. Remove the spacing issues, and it should work: unique:users,user_email,etc.

(Note, this is an expanded answer based off of my comment, which solved the user's problem).

Upvotes: 2

Related Questions