illizian/notifications 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

illizian/notifications

Composer 安装命令:

composer require illizian/notifications

包简介

A Laravel 4 package that provides Facebook style notifications

README 文档

README

A basic Laravel package that provides Facebook style notifications. Notifications are assigned to your own User model and are automatically marked as read when that User visits the URL associated with the notification.

Installation

  1. Add to your composer.json $ composer require illizian/notifications
  2. Add the Service Provider to your config/app.php file
'providers' => array(
    // [...]
    'Illizian\Notifications\NotificationsServiceProvider'
)
  1. Update your User model
use Illizian\Notifications\Traits\NotificationableTrait;

class User extends Eloquent
{

    use NotificationableTrait;

    // [...]

}

This package assumes your User model's classname is "User" - see Configuration on how to override this

  1. Run the package migration $ php artisan migrate --package="illizian/notifications"

Usage

The main Class for this package will be automatically aliased to 'Notify' for you, you can then use the class in your controllers to trigger notifications for a User:

$to = User::find(1);
$from = User::find(2);
$msg = 'User 2 has sent you a message';
$url = '/inbox/message'; // This should be a relative URL

Notify::send($to, $from, $msg, $url);

Then you can get the User's notifications from their model:

$notifications = User::find(1)->notifications;

When the User visits /inbox/message the package will detect this and mark the notification as read, alternatively you can manually mark the notification read by providing the notification's ID to the read function:

Notify::read(1)

Routes & Views

The package contains some basic routes & views to get you started. The following routes are available:

Path Description
/notifications/mark_as_read/{id} Mark the notification {id} as read
/notifications/api/all Get all User's notifications as JSON
/notifications/api/unread Get all User's unread notifications as JSON
the prefix can be changed - see Configuration

Configuration

The package contains a basic configuration file. You can import the configuration by running:

$ php artisan config:publish illizian\notifications

统计信息

  • 总下载量: 34
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-03-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固