PHPackages                             princeton255/laravel-notifications-infobip - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. princeton255/laravel-notifications-infobip

AbandonedArchivedLibrary[Mail &amp; Notifications](/categories/mail)

princeton255/laravel-notifications-infobip
==========================================

A custom Laravel notifications channel for Infobip SMS API

1.2.0(6y ago)37.1k3MITPHPPHP &gt;=7.1

Since Nov 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/tumainimosha/laravel-notifications-infobip)[ Packagist](https://packagist.org/packages/princeton255/laravel-notifications-infobip)[ RSS](/packages/princeton255-laravel-notifications-infobip/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (7)Versions (5)Used By (0)

Infobip Notifications Channel for Laravel 5.5+
==============================================

[](#infobip-notifications-channel-for-laravel-55)

[![Latest Stable Version](https://camo.githubusercontent.com/fa603b9547f6d6cd56c9a3ca8443322009b49edfd288ca773e5835519af438e4/68747470733a2f2f706f7365722e707567782e6f72672f7072696e6365746f6e3235352f6c61726176656c2d6e6f74696669636174696f6e732d696e666f6269702f762f737461626c65)](https://packagist.org/packages/princeton255/laravel-notifications-infobip)[![License](https://camo.githubusercontent.com/c3a683c413671e6a669e75d4dbf0916e73afd6ae055ba4a8e4f5c4a3fc9d9cab/68747470733a2f2f706f7365722e707567782e6f72672f7072696e6365746f6e3235352f6c61726176656c2d6e6f74696669636174696f6e732d696e666f6269702f6c6963656e7365)](https://packagist.org/packages/princeton255/laravel-notifications-infobip)[![Total Downloads](https://camo.githubusercontent.com/7999f840ce9575b6279be8dda97395f700b6f117801882ecdb77d10299353125/68747470733a2f2f706f7365722e707567782e6f72672f7072696e6365746f6e3235352f6c61726176656c2d6e6f74696669636174696f6e732d696e666f6269702f646f776e6c6f616473)](https://packagist.org/packages/princeton255/laravel-notifications-infobip)

This package makes it easy to send Sms notifications using [Infobip service](https://dev.infobip.com/) with Laravel 5.5 and above.

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Setting up your Infobip account](#setting-up-your-infobip-account)
- [Usage](#usage)
    - [Available Message methods](#available-message-methods)
- [Examples](#examples)
    - [Dispatching the notification](#dispatching-the-notification)
    - [Example Notification class](#example-notification-class)
    - [Example Notifiable class](#example-notifiable-class)
- [Testing](#testing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require princeton255/laravel-notifications-infobip
```

### Setting up your Infobip account

[](#setting-up-your-infobip-account)

Add your Infobip Account Username, Password, and From Number to your `config/services.php`:

```
// config/services.php
...
'infobip' => [
    'username' => env('INFOBIP_USERNAME'),
    'password' => env('INFOBIP_PASSWORD'),
    'from' => env('INFOBIP_FROM', 'IBTEST'),
],
...
```

To change `Base URL` to personal use this ([See more](https://dev.infobip.com/getting-started/base-url))

```
...
'infobip' => [
    ...
    'baseUrl' => env('INFOBIP_BASE_URL', null),
],
...
```

Usage
-----

[](#usage)

Now you can use the channel in your `via()` method inside the notification:

```
use NotificationChannels\Infobip\InfobipChannel;
use NotificationChannels\Infobip\InfobipMessage;
use Illuminate\Notifications\Notification;

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

    public function toInfobip($notifiable)
    {
        return (new InfobipMessage())
            ->content("Your {$notifiable->service} account was approved!");
    }
}
```

In order to let your Notification know which phone are you sending to, the channel will look for the `phone_number` attribute of the Notifiable model. If you want to override this behaviour, add the `routeNotificationForInfobip` method to your Notifiable model.

```
public function routeNotificationForInfobip()
{
    return '+1234567890';
}
```

### Available Message methods

[](#available-message-methods)

#### InfobipMessage

[](#infobipmessage)

- `from('')`: Accepts a phone to use as the notification sender.
- `content('')`: Accepts a string value for the notification body.

Examples
--------

[](#examples)

### Dispatching the notification

[](#dispatching-the-notification)

#### A. Using Laravel's notification facade

[](#a-using-laravels-notification-facade)

```
use App\Notifications\ExampleInfobipNotification;
use Illuminate\Support\Facades\Notification;

Notification::send($user, new ExampleInfobipNotification());

// where $user implements `Illuminate\Notifications\Notifiable` trait
```

#### B. Using the `notify()` method from `Notifiable` trait

[](#b-using-the-notify-method-from-notifiable-trait)

```
use App\Notifications\ExampleInfobipNotification;

$user->notify(new ExampleInfobipNotification($invoice));
```

### Example Notification class

[](#example-notification-class)

```
