PHP code example of ooriyap / filament-simple-otp

1. Go to this page and download the library: Download ooriyap/filament-simple-otp 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/ */

    

ooriyap / filament-simple-otp example snippets


use OoriyaP\FilamentSimpleOtp\SimpleOtpPlugin;
use OoriyaP\FilamentSimpleOtp\Drivers\SmsIrDriver;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(
            SimpleOtpPlugin::make()
                ->adminModel(\App\Models\User::class)
                ->otpCode(length: 6, expiresIn: 180)
                ->rateLimit(attempts: 5, decaySeconds: 60)
                ->resendLimit(attempts: 3, decaySeconds: 60)
                ->driver(SmsIrDriver::class)
                ->profilePage(enabled: true)
                ->adminResource(enabled: true)
        );
}

use OoriyaP\FilamentSimpleOtp\Drivers\LogDriver;

SimpleOtpPlugin::make()
    ->driver(LogDriver::class)

use OoriyaP\FilamentSimpleOtp\Contracts\OtpDriverContract;

class KavenegarDriver implements OtpDriverContract
{
    public function sendOtp(string $mobile, string $code): bool
    {
        // Send SMS logic via your preferred provider
        return true;
    }
}

SimpleOtpPlugin::make()
    ->driver(KavenegarDriver::class)
bash
php artisan vendor:publish --tag="filament-simple-otp-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="filament-simple-otp-config"
bash
php artisan vendor:publish --tag="filament-simple-otp-translations"