PHP code example of teh9 / laravel2fa

1. Go to this page and download the library: Download teh9/laravel2fa 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/ */

    

teh9 / laravel2fa example snippets

 
'api_key' => 'YOUR_BOT_API_KEY'
 
class User extends Model implements TelegramTwoFactor
{
    use HasAuth;
}
 
$user = User::first();
// Might be passed 2 params
// 1-st preffered length of code by default 6
// 2-nd is language by default en
$user->sendCode(4, 'ru'); // return boolean
 
// The received code from the telegram must be passed to the method, which is described below
$code = 'CODE_FROM_TELEGRAM'; 
$user = User::first();
$user->validateCode($code); // return boolean

php artisan vendor:publish --provider="Teh9\Laravel2fa\TelegramTwoFactorServiceProvider"
 
php artisan migrate