topcu/toplusmslaravel

There is no license information available for the latest version (v1.0.2) of this package.

Laravel Notification for toplusmsapi.com

v1.0.2 2017-04-25 08:03 UTC

This package is not auto-updated.

Last update: 2024-04-14 01:36:05 UTC


README

Introduction

This is a simple Notifications channel for Laravel.

Installation

First, you'll need to require the package with Composer:

composer require topcu/toplusmslaravel

Aftwards, run composer update from your command line.

Then, update config/app.php by adding an entry for the service provider.

'providers' => [
	// ...
    Topcu\TopluSms\TopluSmsProvider::class,
];

Then, update config/services.php by adding your toplusms credentials.

return [
   // ...
	,
        'toplusms' => [
            'username' => env('TOPLUSMS_USERNAME'),
            'password' => env('TOPLUSMS_PASSWORD'),
            'from' => env('TOPLUSMS_FROM', null), // Can be ovverdiden with $message->from() 
        ]
    // ...
];

Usage

Routing sms notifications

In order to send sms messages, you need to specify recipient for each notifiable entity. For instance in app/user.php

    // ...
    public function routeNotificationForSms(){
        return $this->phone;
    }
    // ...

Sending notification

via Method

In your notification class you can define channel as:

    // ...
    public function via($notifiable)
    {
        return ['sms'];
    }
    // ...

toSMS Method

You also need to define, toSms method. You can:

  1. Send a simple string as:
    // ...
    public function toSms($notifiable)
    {
        return "Hello World!";
    }
    // ...
  1. Or define a from (sender) to override config:
    // ...
    public function toSms($notifiable)
    {
       $message = new SmsMessage("Hello World");
       $message->from("5xxxxxxxxx");
       return $message;
    }
    // ...