2017 © Pedro Peláez
 

library laravel-stream-notification-channel

Stream Notifications Channel for Laravel 5.3

image

techinasia/laravel-stream-notification-channel

Stream Notifications Channel for Laravel 5.3

  • Wednesday, February 8, 2017
  • by techinasia
  • Repository
  • 12 Watchers
  • 1 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Stream Notification Channel for Laravel

Dependency Status Build Status Coverage Status StyleCI Status, (*1)

Use Laravel 5.3 notifications to send activities to Stream., (*2)

Contents

Installation

Install this package with Composer: ``` bash composer require techinasia/laravel-stream-notification-channel-notification-channel, (*3)


Register the service provider in your `config/app.php`: ``` php NotificationChannels\GetStream\StreamServiceProvider::class

Setting up Stream

This notification channel uses techinasia/laravel-stream to send notifications to Stream., (*4)

Publish all the vendor assets: ``` bash php artisan vendor:publish, (*5)


This will create a file called `stream.php` in the `config` folder. Create an application via [Stream's](https://getstream.io) admin interface and copy the API key and secret to the configuration file. You can add more applications by adding more key/secret pairs to the configuration file: ``` php 'applications' => [ 'main' => [ 'key' => 'key1', 'secret' => 'secret1', ], 'foo' => [ 'key' => 'foo', 'secret' => 'bar', ], ],

Usage

Send notifications via Stream in your notification:, (*6)

``` php use NotificationChannels\GetStream\StreamChannel; use NotificationChannels\GetStream\StreamMessage; use Illuminate\Notifications\Notification;, (*7)

class TestNotification extends Notification { public function via($notifiable) { return [StreamChannel::class]; }, (*8)

public function toStream($notifiable)
{
    return (new StreamMessage())
        ->actor(1)
        ->verb('like')
        ->object(3)
        ->foreignId('post:42');
}

}, (*9)


You need to specify the ID and type of the notifiable by defining a `routeNotificationForStream` method on the entity: ``` php /** * Notification routing information for Stream. * * @return array */ public function routeNotificationForStream() { return [ 'type' => 'user', 'id' => $this->id, ]; }

Available Message methods

  • application(string $application): Sets the application to be used to send the notification.

You can set any attributes of the payload by calling the name of the attribute in camel case with the value as the parameter:, (*10)

``` php return (new StreamMessage()) ->actor(1) ->verb('like') ->object(3);, (*11)


## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information for what has changed recently. ## Testing ``` bash composer test

Security

If you discover any security related issues, please email dev@techinasia.com instead of using the issues tracker., (*12)

Contributing

Please see CONTRIBUTING for details., (*13)

Credits

License

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

The Versions