zerockvnext/notice 问题修复 & 功能扩展

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

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

zerockvnext/notice

Composer 安装命令:

composer require zerockvnext/notice

包简介

README 文档

README

This library is a concise web application notification center to Laravel 5

I have only tested on Laravel 5, not sure if it's available on Laravel4.

Contents

Installation

  1. Install use composer
composer require "zerockvnext/notice:~1.0"
  1. Open your config/app.php and add the following to the providers array:
ZerockvNext\Notice\NoticeServiceProvider::class,
  1. In the same config/app.php and add the following to the aliases array:
'Notice' => ZerockvNext\Notice\NoticeFacade::class,
  1. Run the command below to publish the package config & migration files:
php artisan vendor:publish --provider="ZerockvNext\Notice\NoticeServiceProvider"
  1. Run migrate
php artisan migrate

Configuration

  1. Open your config/notice.php and add the following to the orm array:
'orm' => [
    'user' => \App\User::class
],

chang it to your User ORM

Usage

Send Message

    Notice::PostOffice()
        ->type(Notice::Consts()->typeMessage())
        ->sender(1) // Sender ID
        ->title('test message')
        ->message('message contents. this is a test message!')
        ->addReceiver(2) // Receiver ID
        ->addReceivers([3, 4, 5, 6, 7]) // Receivers
        ->send();

In this code, title() and message() are not necessary.

Notice::Consts()->typeMessage() // message, someone send message to someone else.
Notice::Consts()->typeNotice() // notice, announcement by someone.
Notice::Consts()->typeSystem() // system, messages sent by the system.

type() can receive 'message', 'notice' and 'system', default type is 'message'.

MailBox

Receive Message

$Messages = Notice::MailBox()
    ->receiver(4) // Receiver ID
    ->getPagedMessages(1, 10); // Page, Limited, Type = null

$Totals = Notice::MailBox()
    ->totalMessages(); // Type = null

return [
    'messages' => $Messages, // Paged messages
    'totals'   => $Totals, // Total count of messages
];

or like this

Notice::MailBox()->receiver(4) // Receiver ID
$Messages = Notice::MailBox()->getPagedMessages(1, 10, Notice::Consts()->typeMessage());
$Totals   = Notice::MailBox()->totalMessages(Notice::Consts()->typeMessage());

return [
    'messages' => $Messages, // Paged messages
    'totals'   => $Totals, // Total count of messages
];

If you set the value of $Type, then this method will return the result of the corresponding type.

Count Messages

Notice::MailBox()->receiver(4);

Notice::MailBox()->hasUnread(); // Type = null, return bool
Notice::MailBox()->hasUnread(Notice::Consts()->typeMessage());

Notice::MailBox()->totalUnread(); // Type = null, return unread count num
Notice::MailBox()->totalUnread(Notice::Consts()->typeMessage());

Notice::MailBox()->totalMessages(); // Type = null, return count num
Notice::MailBox()->totalMessages(Notice::Consts()->typeMessage());

Notice::MailBox()->countUnread(); // Type = null
// return array like this ['message' => 5, 'notice' => 2, 'system' => 3]

Notice::MailBox()->countUnread(Notice::Consts()->typeMessage());
// return array like this ['message' => 5]

Get Specified Message

$Message = Notice::MailBox()->receiver(4)->getTransfer(1) // Transfer ID

return [
    'message' => $Message, // Message
];

Note: Only message for this receiver can be obtained.

Read / Unread

Notice::MailBox()->receiver(4)->read(1) // Transfer ID
Notice::MailBox()->receiver(4)->read([1,2,3,4]) // Transfer IDs

Notice::MailBox()->receiver(4)->readAll();
Notice::MailBox()->receiver(4)->readAll(Notice::Consts()->typeMessage()); // Type

Notice::MailBox()->receiver(4)->unread(1) // Transfer ID
Notice::MailBox()->receiver(4)->unread([1,2,3,4]) // Transfer IDs

Note: Only the corresponding receiver can modify message status.

Remove Message

Notice::MailBox()->receiver(4)->remove(1) // Transfer ID
Notice::MailBox()->receiver(4)->remove([1,2,3,4]) // Transfer IDs

View Remove Message

Notice::MailBox()->mode(Notice::Consts()->modeRecycled());

$Messages = Notice::MailBox()
    ->receiver(4)
    ->getPagedMessages(1, 10);

$Totals = Notice::MailBox()->totalMessages();

return [
    'messages' => $Messages, // Paged messages
    'totals'   => $Totals, // Total count of messages
];

you can use those values:

Notice::Consts()->modeAll() // return null, all messages
Notice::Consts()->modeWithoutRecycled() // return true, default, only not recycled
Notice::Consts()->modeRecycled() // return false, only recycled

License

MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固