2017 © Pedro Peláez
 

library laravel-nowsms

NowSMS service provider for Laravel

image

junityco/laravel-nowsms

NowSMS service provider for Laravel

  • Tuesday, February 6, 2018
  • by Junity
  • Repository
  • 1 Watchers
  • 0 Stars
  • 77 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 3 % Grown

The README.md

NowSMS for Laravel

This package makes it easy to send NowSMS notifications with Laravel., (*1)

Total Downloads Latest Version License, (*2)

Installation

Require this package, with Composer, in the root directory of your project., (*3)

$ composer require junityco/laravel-nowsms

Add the service provider to config/app.php in the providers array., (*4)

Junity\NowSms\NowSmsServiceProvider::class

If you want you can use the facade. Add the reference in config/app.php to your aliases array., (*5)

'NowSms' => Junity\NowSms\Facades\NowSms::class

You will also need to install guzzlehttp/guzzle http client to send requests., (*6)

Setting up your NowSMS account

Add your NowSMS url, username, password config/services.php:, (*7)

// config/services.php
...
'nowsms' => [
    'url' => 'http://127.0.0.1:8800',
    'username' => '',
    'password' => '',
],
...

Usage

Now you can use the channel in your via() method inside the notification:, (*8)

``` php use Junity\NowSms\Messages\SmsMessage; use Junity\NowSms\Channels\NowSmsChannel; use Illuminate\Notifications\Notification;, (*9)

class AccountApproved extends Notification { public function via($notifiable) { return [NowSmsChannel::class]; }, (*10)

public function toNowSms($notifiable)
{
    return (new SmsMessage)
        ->from("SenderID")
        ->content("Your account was approved!");
}

}, (*11)


In order to let your Notification know which phone are you sending/calling to, the channel will look for the `phone_number` attribute of the Notifiable model. If you want to override this behaviour, add the `routeNotificationForNowsms` method to your Notifiable model. ```php public function routeNotificationForNowsms() { return '+1234567890'; }

Example using via code

use Junity\NowSms\Facades\NowSms;

NowSms::send([
    'Text' => 'Some text',
    'Sender' => 'MyApp',
], '+1234567890');

The Versions