1. Go to this page and download the library: Download visualbuilder/filament-2fa 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/ */
use Visualbuilder\Filament2fa\Contracts\TwoFactorAuthenticatable;
use Visualbuilder\Filament2fa\Traits\TwoFactorAuthentication;
class Admin extends Authenticatable implements FilamentUser, TwoFactorAuthenticatable
{
use HasFactory, TwoFactorAuthentication;
}
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->plugins([
TwoFactorPlugin::make()
])
}
use Visualbuilder\Filament2fa\Filament\Pages\Login;
public function panel(Panel $panel): Panel
{
return $panel
->default()
->id('admin')
->plugins([
TwoFactorPlugin::make()
])
->login(Login::class)
->userMenuItems([
/**
* 2FA setup and manage link
*/
MenuItem::make('two-factor')
->url('/two-factor-authentication')
->label('Two Factor Auth')
->icon('heroicon-o-key')
->sort(1),
/**
* Banner manager
* Ensure you limit access to who can change banners
*/
MenuItem::make('two-factor-banner')
->url(config('filament-2fa.banner.navigation.url'))
->label(config('filament-2fa.banner.navigation.label'))
->icon(config('filament-2fa.banner.navigation.icon'))
->sort(2)
->visible(fn() => Filament::auth()->user()->hasRole(['Developer', 'Super Admin'],'web'))