vendredi 29 avril 2016

Laravel 5.1 - Create user using Socialite and set confirmed column to 1

I've got socialite working really well in my Laravel app. I do however have one small issue.

By default, all accounts have a confirmed column that is set to 0, as some users are using social profiles, I would like to set their confirmed column to 1 instantly after successful integration with their social profile.

This is my column code from my migration:

Schema::table('users', function (Blueprint $table) {
    $table->boolean('confirmed')->default(0);
    $table->string('confirmation_code')->nullable();
});

And this is my create code inside my socialite auth controller:

$new_user = User::create([
    'name' => $user->name,
    'email' => $user->email,
    'oauth_facebook_id' => $provider === 'facebook' ? $user->id : NULL,
    'oauth_twitter_id' => $provider === 'twitter' ? $user->id : NULL,
    'confirmed' => 1,
    'avatar' => $user->avatar
]);

Even though confirmed is set to 1, it still makes the account with a 0.

Am I missing something?

Andy



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire