1. Go to this page and download the library: Download envoisms/laravel-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/ */
namespace App\Notifications;
use EnvoiSMS\Laravel\EnvoiSMSChannel;
use EnvoiSMS\Laravel\Messages\EnvoiSMSMessage;
use Illuminate\Notifications\Notification;
class SendOtpNotification extends Notification
{
public function via($notifiable): array
{
return [EnvoiSMSChannel::class];
}
public function toEnvoiSMS($notifiable): EnvoiSMSMessage
{
return (new EnvoiSMSMessage())
->asOtp(brand: 'MonApp', codeLength: 6, expiry: 600);
}
}
$user->notify(new SendOtpNotification());
public function toEnvoiSMS($notifiable): EnvoiSMSMessage
{
return (new EnvoiSMSMessage())
->content("Bonjour {$notifiable->first_name}, votre commande #{$this->order->id} est expédiée.")
->from('MonBusiness'); // validated Sender ID, or omit for the account default
}