Skip to content
Ayomide Olakulehin edited this page Mar 31, 2022 · 6 revisions

Usage

Available Methods

Notifications Channel

You can also use Termii channel in your via() method inside the notification:

use Corbancode\TermiiLaravel\Notifications\TermiiChannel;
use Corbancode\TermiiLaravel\Notifications\TermiiMessage;
use Illuminate\Notifications\Notification;

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

    public function toTermii($notifiable)
    {
        return (new TermiiMessage())
            ->content("[Your App] confirmation code is 548434. It expires in 5 minutes.");
    }
}

In order to let your Notification know which phone number you are sending to, add the routeNotificationForTermii method to your Notifiable model

public function routeNotificationForTermii()
{
    return $this->phone; // where `phone` is a field in your users table;
}

Available Message methods

TermiiMessage
  • from(''): Accepts a sender ID to use as the notification sender. TERMII_SMS_FROM .env value would be used as default incase this method is not used.
  • content(''): Accepts a string value for the notification body.
  • channel(''): Accepts a string value for the sms channel. Defaults to "generic" incase this method is not used.
  • media(): Accepts an array value for the media.
Clone this wiki locally