Skip to content

undjike/cleansms-notification-channel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

Latest Stable Version License Total Downloads Dependents

Introduction

This is a package for Laravel Applications which enables you to send notifications through CleanSMS Channel.

The package uses undjike/cleansms to perform SMS dispatching.

Installation

This package can be installed via composer. Just type :

composer require undjike/cleansms-notification-channel

Usage

After installation, configure your services in congig/services.php by adding :

<?php

return [
    //...

    'cleansms' => [
        'apikey' => env('CLEANSMS_APIKEY'), // You can type in directly your credentials 
        'email' => env('CLEANSMS_EMAIL')
    ],
];

Once this is done, you can create your notification as usual.

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use Undjike\CleanSmsNotificationChannel\Channel\CleanSmsChannel;
use Undjike\CleanSmsNotificationChannel\CleanSmsMessage;

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

    /**
     * @param $notifiable
     * @return mixed
     */
    public function toCleanSms($notifiable)
    {
        return CleanSmsMessage::create()
            ->body('Type here you message content...')
            ->transactional();
        // or return 'Type here you message content...';
    }
}

To get this stuff completely working, you need to add this to your notifiable model.

    /**
     * Attribute to use when addressing CleanSMS notification
     *
     * @returns string|array
     */
    public function routeNotificationForCleanSms()
    {
        return $this->phone_number; // Can be a string or an array of valid phone numbers
    }

Enjoy !!!

License

The MIT License (MIT). Please see License File for more information.

About

Laravel Notification Channel based on CleanSMS service

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages