inpin/lara-alert
Composer 安装命令:
composer require inpin/lara-alert
包简介
Add Alertable trait to Laravel Eloquent models
README 文档
README
Trait for Laravel Eloquent models to allow easy implementation of a "user alerts" feature.
Composer Install (for Laravel 5.5 and above)
composer require inpin/lara-alert
Install and then run the migrations
'providers' => [ \Inpin\LaraAlert\LaraAlertServiceProvider::class, ],
php artisan vendor:publish --provider="Inpin\LaraAlert\LaraAlertServiceProvider" --tag=migrations
php artisan migrate
Model and database schema
it will create you a table of laraalert_alerts with following fields:
type is the type of alert, ex: 'alert', 'confirmation complete', 'software update, etc.
description a nullable text which describe alert.
seen_at determines if current alert is new (seen_at is null_) or not (seen_at fills with timestamp)
Setup your models
class Book extends \Illuminate\Database\Eloquent\Model { use Inpin\LaraAlert\Alertable; }
Sample Usage
// Create an alert with type of 'alert' by currently logged in user without description. $book->createAlert(); // Create a alert on $book object with type of "some-alert-type", and null description. $book->createAlert('some-alert-type'); // Create a alert on $book object with type of "some-alert-type", null description, // and current logged in user form 'api' guard as owner. $book->createAlert('some-alert-type', 'api'); // Create a alert on $book object with type of "some-alert-type", null description, and $user as owner. $book->createAlert('some-alert-type', $user); // Create a alert on $book object with type of "some-alert-type", with description of "some message, // and current logged in user form 'api' guard as owner. $book->createAlert('some-alert-type', 'api', 'some message'); // Create a alert on $book object with type of "some-alert-type", with description of "some message, // and current logged in user form 'api' guard as owner. $book->createAlert('some-alert-type', $user, 'some message'); // Create a alert on $book object with "alert item id" of 1 and 2, put user message of "some message on it", // and put $user (3rd param) as alerter. $book->createAlert([1, 2], 'some message', $user'); $book->alerts(); // HasMany relation to alerts of book. $book->alerts; // Collection of book's alerts. $book->isAlertedBy() // check if current logged in user form default guard has alerted book. $book->isAlertedBy('api') // check if current logged in user form 'api' guard has alerted book. $book->isAlertedBy($user) // check if '$user' has alerted book. $book->isAlerted() // check if $book has alert. $book->isAlerted // check if $book has alert. $book->alertsCount; // return number of alerts on $book. $book->alertsCount(); // return number of alerts on $book.
Alert objects
// set seen_at with current timestamp. $alert->seen(); // check if $alert is new or not. $alert->isNew(); $alert->isNew; // check if $alert is seen or not. $alert->isSeen(); $alert->isSeen;
Credits
- Mohammad Nourinik - http://inpinapp.com
inpin/lara-alert 适用场景与选型建议
inpin/lara-alert 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 910 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「store」 「notification」 「trait」 「laravel」 「push」 「eloquent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 inpin/lara-alert 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inpin/lara-alert 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 inpin/lara-alert 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
Trait providing methods to set class properties with an array.
Admin Hub for GetCandy. A modern headless e-commerce solution for Laravel PHP framework.
Expansion traits for Yii2 components
Apple Push Notification & Feedback Provider
Traits to build collections of specific objects
统计信息
- 总下载量: 910
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-04