fahmiardi / laravel-notification by fahmiardi

Various laravel notifications channels
226
0
1
Package Data
Maintainer Username: fahmiardi
Maintainer Contact: f4hem.net@gmail.com (Fahmi Ardi)
Package Create Date: 2016-12-15
Package Last Update: 2016-12-15
Language: PHP
License: MIT
Last Refreshed: 2024-04-18 15:23:02
Package Statistics
Total Downloads: 226
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

More Laravel Notification Providers

Available Channels:

  • AWS SNS (Simple Notification Services), support using credentials or profile

Install

$ composer require fahmiardi/laravel-notification

Setup

Add config to app/services.php:

return [
    ...
    'sns' => [
        'key' => env('SNS_KEY'),
        'secret' => env('SNS_SECRET'),
        'region' => env('SNS_REGION'),
        'profile' => env('AWS_PROFILE'), // keep this value empty when using credentials
    ],
];

Usage

Use generic:

<?php

$user->notify(
    new \Fahmiardi\Laravel\Notifications\GenericSnsNotification($topicArn, $subject, $message)
);

Create your own:

Read the official page https://laravel.com/docs/5.3/notifications#creating-notifications

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use Fahmiardi\Laravel\Notifications\Channels\SnsChannel;
use Fahmiardi\Laravel\Notifications\Messages\SnsMessage;

class InvoicePaid extends Notification
{
    protected $invoice;

    public function __construct($invoice)
    {
        $this->invoice = $invoice;
    }

    public function via($notifiable)
    {
        return [SnsChannel::class];
    }

    public function toSns($notifiable)
    {
        return (new SnsMessage)
            ->topicArn('ARN')
            ->subject('SUBJECT')
            ->message('MESSAGE');
    }
}

$user->notify(new InvoicePaid($invoice));