PHP code example of mahdialikhani / otp-authenticator

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

    

mahdialikhani / otp-authenticator example snippets


'kavenegar' => [
    'line_number' => ''
]

return (new KavenegarMessage)
            ->to('09301111111')
            ->message('Hi dear, your verification code is:123456');

'ghasedak' => [
    'template_name' => ''
]

return (new GhasedakMessage)
            ->to('09301111111')
            ->message('123456');



namespace App\Notifications\Messages;

use Mahdialikhani\OtpAuthenticator\Contracts\Messageable;
use Mahdialikhani\OtpAuthenticator\Notifications\Messages\SimpleMessage;

class SmsirMessage extends SimpleMessage implements Messageable
{
    public function send()
    {
        // Code here
    }
}




namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use Mahdialikhani\OtpAuthenticator\Notifications\Channels\SmsChannel;

class VerificationNotification extends Notification
{
    use Queueable;

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [SmsChannel::class];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toSms($notifiable)
    {
        return (new SmsirMessage)
            ->to('09301111111')
            ->message('123456');
    }
}



namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class VerificationNotification extends Notification
{
    use Queueable;

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return \Illuminate\Notifications\Messages\MailMessage
     */
    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->line('The introduction to the notification.')
            ->action('Notification Action', url('/'))
            ->line('Thank you for using our application!');
    }
}
 bash
php artisan vendor:publish --tag=otpauthenticator

php artisan otp:install