On registering with new email, I can successfully register the new user, but when I try to make a validation rule
to restrict an existing email from signup, instead of giving validation error message, its giving me Integrity constraint violation error
,
here is my controller
public function postRegister(Request $request){
$v = validator::make($request->all(), [
'first_name' => 'required|max:30',
'last_name' => 'required|max:30',
'email' => 'required|unique:users|email',
'mobile' => 'required|min:10',
'password' => 'required|min:8',
'confirm_password' => 'required|same:password'
]);
if ($v->fails())
{
return redirect()->back()
->withErrors($v->errors())
->withInput(Input::except('password', 'confirm_password'));
}
else{
// validation successful ---------------------------
/*
add data to database
*/
}
and this is my migration
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name', 80);
$table->string('last_name', 80);
$table->string('email')->unique();
$table->string('mobile',80);
$table->string('password', 60);
$table->boolean('confirmed')->default(0);
$table->string('confirmation_code')->nullable();
$table->float('amount', 80);
$table->rememberToken();
$table->timestamps();
});
}
How can I fix this error? Any help appreciated.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NYGywP
via IFTTT
Aucun commentaire:
Enregistrer un commentaire