PHP code example of mrkatz / login-providers

1. Go to this page and download the library: Download mrkatz/login-providers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mrkatz / login-providers example snippets


use Mrkatz\LoginProviders\Traits\HasLoginProviders;

class User extends Authenticatable
{
use Notifiable, HasLoginProviders;
}

use Mrkatz\LoginProviders\Traits\UsesLoginProviders;

class RegisterController extends Controller
{
use RegistersUsers, UsesLoginProviders;
}

php artisan vendor:publish --provider="Mrkatz\LoginProviders\LoginProvidersServiceProvider" --tag="config"

    public function create(array $input)
    {
        if (!array_key_exists('social')) {
            return $this->createSocialUser($input);
        }
        
        ...

/**
     * Create a newly registered Social user.
     *
     * @param array $input
     * @return \App\Models\User
     * @throws \Throwable
     */
    protected function createSocialUser(array $input)
    {
        return DB::transaction(function () use ($input) {
            return tap(User::create([
                'name' => $input['name'],
                'email' => $input['email'],
                'password' => Hash::make($input['password']),
            ]), function (User $user) {
                $this->createTeam($user);
            });
        });
    }
`
    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\Models\User
     */
    protected function create(array $data)
    {
        if (!array_key_exists('social')) {
            return $this->createSocialUser($data);
        }
        
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($input['password']),
        ]);
    }

/**
     * Create a newly registered Social user.
     *
     * @param array $input
     * @return \App\Models\User
     * @throws \Throwable
     */
    protected function createSocialUser(array $data)
    {
       return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
    }