hotrush/laravel-log-notification-channel

Log notifications channel for laravel
2,297 1
Install
composer require hotrush/laravel-log-notification-channel
Latest Version:0.4.0
PHP:>=5.5.9
License:MIT
Last Updated:Jul 17, 2023
Links: GitHub  ·  Packagist
Maintainer: hotrush

Laravel log notifications channel

Latest Version on Packagist Software License Total Downloads

Send notifications into log with Laravel, easier to pretend other services e.g. sms or push notifications.

Contents

Installation

composer require hotrush/laravel-log-notification-channel

Setting up the log service

You can add LOG_NOTIFICATIONS_CHANNEL into your .env file to customize log channel to use, otherwise default one will be used.

Usage

<?php

namespace App\Notifications;

use App\Post;
use Illuminate\Notifications\Notification;
use NotificationChannels\Log\LogChannel;
use NotificationChannels\Twilio\TwilioChannel;
use NotificationChannels\Log\LogMessage;


class AuthCodeCreatedNotification extends Notification
{
    /**
     * @var Post
     */
    private $post;

    /**
     * Create a new notification instance.
     *
     * @param Post $post
     * @return void
     */
    public function __construct(Post $post)
    {
        $this->post = $post;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return app()->environment('production')
            ? [TwilioChannel::class]
            : [LogChannel::class];
    }

    /**
     * Get the log message representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return LogMessage
     */
    public function toLog($notifiable)
    {
        return new LogMessage('Pretended sms send to :number and with content: :content');
    }
}

License

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

Related Packages

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444