PHP code example of gabrielesbaiz / nova-two-factor
1. Go to this page and download the library: Download gabrielesbaiz/nova-two-factor 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/ */
gabrielesbaiz / nova-two-factor example snippets
use Laravel\Fortify\Features;
Nova::fortify()->features([
Features::twoFactorAuthentication(['confirm' => true, 'confirmPassword' => true]),
]);
use Gabrielesbaiz\NovaTwoFactor\Concerns\HasTwoFactorAuthentication;
class User extends Authenticatable
{
use HasTwoFactorAuthentication;
}
use Gabrielesbaiz\NovaTwoFactor\NovaTwoFactor;
public function tools(): array
{
return [
NovaTwoFactor::make(),
];
}
use Gabrielesbaiz\NovaTwoFactor\NovaTwoFactor;
Nova::mainMenu(fn ($request) => [
MenuSection::dashboard(Main::class)->icon('chart-bar'),
MenuGroup::make(__('Two-factor'), NovaTwoFactor::menuItems()),
MenuItem::resource(User::class),
NovaTwoFactor::menuSection(), // or the whole group as a top-level entry
]);
use Gabrielesbaiz\NovaTwoFactor\Nova\Actions\ResetTwoFactorAuthentication;
use Gabrielesbaiz\NovaTwoFactor\Nova\Actions\RevokeTrustedDevices;
use Gabrielesbaiz\NovaTwoFactor\Nova\Actions\SendEnrollmentReminder;
use Gabrielesbaiz\NovaTwoFactor\Nova\Fields\TwoFactorStatus;
use Gabrielesbaiz\NovaTwoFactor\Nova\Metrics\TwoFactorAdoption;
use Gabrielesbaiz\NovaTwoFactor\Nova\Metrics\TwoFactorFailures;
use Gabrielesbaiz\NovaTwoFactor\Nova\Metrics\TwoFactorMethodMix;
public function fields(NovaRequest $request): array
{
return [
// Sortable via subquery, so it does not N+1 a large index.
TwoFactorStatus::make(),
];
}
public function actions(NovaRequest $request): array
{
return [
ResetTwoFactorAuthentication::make(), //
use Gabrielesbaiz\NovaTwoFactor\Facades\TwoFactor;
TwoFactor::extend('yubico-otp', fn ($app) => new YubicoDriver(...));