infinety-es/notifications

Notification messages system

1.0.1 2016-06-24 12:15 UTC

This package is auto-updated.

Last update: 2021-11-12 16:59:07 UTC


README

Latest Version on Packagist Total Downloads Software License StyleCI

A package to manage Notifications

With this package you can send notifications to your model. You can choose if you want users, or whatever model.

Notifications are saved on notifications and each item of your model can retrieve it. Also you can set each notification as read.

Installation

Install via composer: composer require infinety-es\notifications

Then register the service provider in config/app.php inside providers array:

Infinety\Notifications\NotificationsServiceProvider::class,

Publish package files:

php artisan vendor:publish --provider="Infinety\Notifications\NotificationsServiceProvider"

Tip: You can also publish only this tags: config, views and migrations

After modify config\notifications.php file NotificationTraitto your model. For example User model:

<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Infinety\Notifications\Traits\NotificationTrait;

class User extends Authenticatable
{

    use NotificationTrait;

Use

In your browser go to notifications. Example: www.infinety.app/notifications.

Default pages are in resources\views\vendor\notifications. You can view and create notifications with a simple interface. You can modify everything.

Command

You can create notifications by artisan with command:

php artisan notifications:new

You have some options you need to add. If not, the command will ask you. Options are:

--notify[=NOTIFY]    A model ID, or all
--subject[=SUBJECT]  Notification subject
--message[=MESSAGE]  Notification message
--type[=TYPE]        Type of notifications defined in config file

Trait Methods

Get all notifications

    /**
     * Get All Notifications. Readed or not
     *
     * @return Eloquent
     */
    public function notifications()

This method retrieves all notifications read and not read notifications

Get not read notifications

    /**
     * Get not read notifications
     *
     * @return Eloquent
     */
     public function getNotReadNotifications()

This method retrieves not read notifications

Get read notifications

    /**
     * Get read Notifications
     *
     * @return Eloquent
     */
    public function getReadNotifications()

This method retrieves read notifications. It's great if you want to show history.

Get count of all notifications

    /**
     * Get Count of all Notifications
     *
     * @return integer
     */
    public function getAllNotificationCount()

Get count of all notifications including read and not read.

Get count of not read notifications

    /**
     * Get Count of not read Notifications
     *
     * @return integer
     */
    public function getNotReadNotificationCount()

Get count of all notifications not read.

Contributing

All contributions (in the form on pull requests, issues and feature-requests) are welcome. See the contributors page for all contributors.

##License

Laravel 5 Notifications is an open-sourced laravel package licensed under the MIT License (MIT). Please see the license file for more information.