irajtaghlidi/laravel-asanak-sms

Asanak.com Notifications channel for Laravel 5.3+

1.0.3 2019-03-25 11:28 UTC

This package is auto-updated.

Last update: 2024-12-06 02:56:41 UTC


README

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using asanak.com with Laravel 5.3+.

  • You can use Queue with Redis to speed up your application.

Contents

Installation

You can install the package via composer:

composer require irajtaghlidi/laravel-asanak-sms

Then you must install the service provider:

// config/app.php
'providers' => [
    ...
    NotificationChannels\AsanakSms\AsanakSmsServiceProvider::class,
],

Setting up the AsanakSms service

Add your AsanakSms login, username/password and default sender number to your config/services.php:

// config/services.php
...
'asanaksms' => [
    'username' => env('ASANAK_USERNAME'),
    'password' => env('ASANAK_PASSWORD'),
    'from'     => env('ASANAK_FROM'),
    'apiurl'   => env('ASANAK_APIURL'),
],
...

Usage

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

use Illuminate\Notifications\Notification;
use NotificationChannels\AsanakSms\AsanakSmsMessage;
use NotificationChannels\AsanakSms\AsanakSmsChannel;

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

    public function toAsanakSms($notifiable)
    {
        return AsanakSmsMessage::create("Task #{$notifiable->id} is complete!");
    }
}

You can add a alias to config/app.php :

// config/app.php
'aliases' => [
    ...
    'asanaksms' => NotificationChannels\AsanakSms\AsanakSmsChannel::class,
],

You can use alias instead of class name in via() method:

use Illuminate\Notifications\Notification;
use NotificationChannels\AsanakSms\AsanakSmsMessage;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return ['asanaksms'];
    }

    public function toAsanakSms($notifiable)
    {
        return AsanakSmsMessage::create("Task #{$notifiable->id} is complete!");
    }
}

In your notifiable model (for example App/User Model), make sure to include a routeNotificationForAsanaksms() method, which returns a phone number or an array of phone numbers.

public function routeNotificationForAsanaksms()
{
    return $this->phone;
}

Available methods

from(): Sets the sender's phone number.

content(): Set a content of the notification message.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email irajtaghlidi@gmail.com instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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