PHP code example of yudina / laravel-sms

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

    

yudina / laravel-sms example snippets

 bash
php artisan vendor:publish --provider="Yudina\LaravelSms\SmsSenderServiceProvider"
 php
use Yudina\LaravelSms\SmsSenderChannel;
use Yudina\LaravelSms\SmsSenderMessage;

use Illuminate\Notifications\Notification;

class CodeGenerationNotification extends Notification
{
    public function via($notifiable)
    {
        return [SmsSenderChannel::class];
    }

    public function toSms($notifiable)
    {
        $message = 'Activation code: ' . $this->generateCode(6);
    
        return new SmsSenderMessage($message);
    }
    
    private function generateCode(int $length): string
    {
        $result = '';

        for($i = 0; $i < $length; $i++)
            $result .= mt_rand(0, 9);

        return $result;
    }
}