2017 © Pedro Peláez
 

library laravel-hooks-notification-channel

Hooks Notifications Driver

image

lukonet/laravel-hooks-notification-channel

Hooks Notifications Driver

  • Friday, August 19, 2016
  • by irazasyed
  • Repository
  • 1 Watchers
  • 6 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Hooks Notifications Channel for Laravel 5.3

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads, (*1)

UPDATE: It seems like the Hooks service is no longer active, hence, this project has been archived., (*2)

This package makes it easy to send notifications using Hooks with Laravel 5.3., (*3)

Hooks API lets you send a notification to all users subscribed to your custom alert., (*4)

Contents

Installation

You can install the package via composer:, (*5)

``` bash composer require lukonet/laravel-hooks-notification-channel, (*6)


You must install the service provider: ```php // config/app.php 'providers' => [ ... NotificationChannels\Hooks\HooksServiceProvider::class, ],

Setting up the Hooks service

  1. Sign up for a developer account on Hooks site.
  2. Get the API Key, located in the account page.
  3. Create a custom alert on alerts page.
  4. Obtain the alert id associated with your notification, located in your alerts page. It'll be used when sending a notification.

Then, configure your Hooks API Key by adding it to the config/services.php file:, (*7)

// config/services.php
...
'hooks' => [
    'key' => env('HOOKS_API_KEY', 'YOUR HOOKS API KEY HERE')
],
...

Usage

You can now use the channel in your via() method inside the Notification class., (*8)

``` php use NotificationChannels\Hooks\HooksChannel; use NotificationChannels\Hooks\HooksMessage; use Illuminate\Notifications\Notification;, (*9)

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

public function toHooks($notifiable)
{
    $url = url('/news/' . $notifiable->id);

    return HooksMessage::create()
        ->alertId('<Hooks Alert ID>') // Optional.
        ->message('Laravel 5.3 launches with the all new notifications feature!')
        ->url($url);
}

}, (*11)


Here's a screenshot preview of the above notification on Hooks App: ![Laravel Hooks Notification Example](https://cloud.githubusercontent.com/assets/1915268/17791360/63550c58-65b8-11e6-84d3-cc5db57a0f80.jpg) ### Routing a message You can either send the notification by providing with the alert id to the `alertId($alertId)` method like shown in the above example or add a `routeNotificationForHooks()` method in your notifiable model: ``` php ... /** * Route notifications for the Hooks channel. * * @return int */ public function routeNotificationForHooks() { return 'YOUR ALERT ID HERE'; } ...

Available Message methods

  • alertId($alertId): (integer) The alert id associated with your notification, located in your alerts page.
  • message(''): (string) The message of the notification.
  • url($url): (string) The related url of this notification.

Changelog

Please see CHANGELOG for more information what has changed recently., (*12)

Testing

bash $ composer test, (*13)

Security

If you discover any security related issues, please email syed@lukonet.com instead of using the issue tracker., (*14)

Contributing

Please see CONTRIBUTING for details., (*15)

Credits

License

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

The Versions

19/08 2016

dev-master

9999999-dev https://github.com/lukonet/laravel-hooks-notification-channel

Hooks Notifications Driver

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel notification hooks hooks notification hooks notifications channel hooks api

19/08 2016

0.0.1

0.0.1.0 https://github.com/lukonet/laravel-hooks-notification-channel

Hooks Notifications Driver

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel notification hooks hooks notification hooks notifications channel hooks api