Laravel 5 Notifications
![Software License][ico-license]
, (*1)
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., (*2)
Notifications are saved on notifications
and each item of your model can retrieve it. Also you can set each notification as read., (*3)
Installation
Install via composer: composer require infinety-es\notifications
, (*4)
Then register the service provider in config/app.php
inside providers
array:, (*5)
Infinety\Notifications\NotificationsServiceProvider::class,
Publish package files:, (*6)
php artisan vendor:publish --provider="Infinety\Notifications\NotificationsServiceProvider"
Tip: You can also publish only this tags: config
, views
and migrations
, (*7)
After modify config\notifications.php
file NotificationTrait
to your model. For example User model:, (*8)
<?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
., (*9)
Default pages are in resources\views\vendor\notifications
. You can view
and create
notifications with a simple interface. You can modify everything., (*10)
Command
You can create notifications by artisan
with command:, (*11)
php artisan notifications:new
You have some options you need to add. If not, the command will ask you. Options are:, (*12)
--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, (*13)
Get not read notifications
/**
* Get not read notifications
*
* @return Eloquent
*/
public function getNotReadNotifications()
This method retrieves not read notifications, (*14)
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., (*15)
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., (*16)
Get count of not read notifications
/**
* Get Count of not read Notifications
*
* @return integer
*/
public function getNotReadNotificationCount()
Get count of all notifications not read., (*17)
Contributing
All contributions (in the form on pull requests, issues and feature-requests) are
welcome. See the contributors page for all contributors., (*18)
License
Laravel 5 Notifications is an open-sourced laravel package licensed under the MIT License (MIT).
Please see the license file for more information., (*19)