PHP code example of tech-djoin / laravel-admin-ext-google-authenticator

1. Go to this page and download the library: Download tech-djoin/laravel-admin-ext-google-authenticator 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/ */

    

tech-djoin / laravel-admin-ext-google-authenticator example snippets


   

   namespace App\Models;

   use Encore\Admin\Auth\Database\Administrator;
   use Illuminate\Notifications\Notifiable;
   use TechDjoin\LaravelAdminGoogleAuthenticator\Traits\Google2FAAuthenticatableTrait;

   class AdminUser extends Administrator
   {
      use Notifiable;
      use Google2FAAuthenticatableTrait;

      protected $fillable = ['username', 'password', 'name', 'avatar', 'google2fa_secret'];

      public function setGoogle2faSecretAttribute($value)
      {
         $this->attributes['google2fa_secret'] = !is_null($value) ? encrypt($value) : null;
      }

      public function getGoogle2faSecretAttribute($value)
      {
         return isset($value) ? decrypt($value) : null;
      }
   }
   

   'auth' => [
       'model' => App\Models\AdminUser::class,
   ],

   'database' => [
      'users_model' => App\Models\AdminUser::class
   ],
   
bash
   php artisan vendor:publish --provider="TechDjoin\LaravelAdminGoogleAuthenticator\GoogleAuthenticatorServiceProvider" --tag="config"
   
bash
   php artisan migrate