infinety-es/notifications

1.0.1 2016-06-24 12:15 UTC

This package is auto-updated.

Last update: 2024-09-12 23:21:47 UTC


README

Latest Version on Packagist Total Downloads Software License StyleCI

用于管理通知的包

使用此包,您可以向您的模型发送通知。您可以选择是用户还是任何模型。

通知存储在 notifications 中,并且您模型中的每个项都可以检索它。您还可以将每个通知设置为已读。

安装

通过 composer 安装: composer require infinety-es\notifications

然后在 config/app.php 文件中的 providers 数组中注册服务提供者

Infinety\Notifications\NotificationsServiceProvider::class,

发布包文件:

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

提示:您还可以仅发布以下标签:configviewsmigrations

修改 config\notifications.php 文件后,将 NotificationTrait 添加到您的模型中。例如,对于用户模型

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

class User extends Authenticatable
{

    use NotificationTrait;

使用

在您的浏览器中转到 notifications。例如:www.infinety.app/notifications

默认页面位于 resources\views\vendor\notifications。您可以使用简单界面 viewcreate 通知。您可以修改一切。

命令

您可以使用 artisan 命令创建通知

php artisan notifications:new

您需要添加一些选项。如果不添加,命令将询问您。选项包括

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

特质方法

获取所有通知

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

此方法检索已读和未读通知

获取未读通知

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

此方法检索未读通知

获取已读通知

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

此方法检索已读通知。如果您想显示历史记录,这将非常有用。

获取所有通知的数量

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

获取包括已读和未读的所有通知的数量

获取未读通知的数量

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

获取所有未读通知的数量

贡献

所有贡献(以拉取请求、问题单和功能请求的形式)都欢迎。请参阅贡献者页面了解所有贡献者。

##许可证

Laravel 5 Notifications 是一个开源的 laravel 包,许可协议为 MIT 许可协议(MIT)。有关更多信息,请参阅许可证文件