vendredi 31 mai 2019

how to fix duplicate entry error in Laravel 5.7?

I am using a user verification system in email with Laravel 5.7 this is working fine. but when I tried to enter the same email with verification form it is generating following massages. SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'mymail@gmail.com' for key 'users_email_unique' (SQL: insert intousers(email,name,address,updated_at,created_at) values (mymail@gmail.com, Banda, Sysney, 2019-05-31 11:32:36, 2019-05-31 11:32:36))

my UserController is like this,

rotected function store(Request $request)
    {

        $user = new User;

        $user->email = $request->input('email');
        $user->name = $request->input('name');
        $user->address = $request->input('address');

        $user->save();

        $verifyUser = VerifyUser::create([
            'user_id' => $user->id,
            'token' => str_random(40)
        ]);

how can fix this problem?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2EKb3ZA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire