Skip to content

rawnoq/laravel-otp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel OTP Package

A professional, production-ready OTP (One-Time Password) package for Laravel applications.

Installation

composer require rawnoq/laravel-otp

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=otp-config

Usage

Generate OTP

use Rawnoq\LaravelOtp\Facades\Otp;

$otp = Otp::generate('user@example.com', 'email');
$code = $otp->otp_code;

Verify OTP

$otp = Otp::verify('user@example.com', '123456', 'email');

if ($otp) {
    // OTP is valid and has been marked as used
}

Check if OTP is Valid

if (Otp::isValid('user@example.com', '123456', 'email')) {
    // OTP is valid
}

Get Latest OTP

$otp = Otp::getLatest('user@example.com', 'email');

Count Active OTPs

$count = Otp::countActive('user@example.com', 'email');

Cleanup Expired OTPs

$deleted = Otp::cleanup();

Delete Active OTPs

Otp::deleteActive('user@example.com', 'email');

Configuration Options

Edit config/otp.php to customize:

  • Default OTP length
  • Default expiry time
  • Dev mode settings
  • Type-specific configurations (phone, email, etc.)

License

MIT

About

A professional, production-ready OTP (One-Time Password) package for Laravel applications.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages