inpin/lara-report
Composer 安装命令:
composer require inpin/lara-report
包简介
Add Reportable trait to Laravel Eloquent models
README 文档
README
Trait for Laravel Eloquent models to allow easy implementation of a "user report" feature.
Composer Install (for Laravel 5.5 and above)
composer require inpin/lara-report
Install and then run the migrations
'providers' => [ \Inpin\LaraReport\LaraReportServiceProvider::class, ],
php artisan vendor:publish --provider="Inpin\LaraReport\LaraReportServiceProvider" --tag=migrations
php artisan migrate
Setup your models
class Book extends \Illuminate\Database\Eloquent\Model { use Inpin\LaraReport\Reportable; }
Sample Usage
Firstly it needs to be seeded in larareport_report_items table.
ReportItem::query()->create([ 'type' => 'books', 'title' => 'Price is incorrect', ]);
the type field is just for categorizing, I suggest to put your model morph name into it.
// Create an empty report by currently logged in user. $book->createReport(); // Create a report on $book object with "report item id" of 1 and 2, with message of null, // and put current logged in user form default guard as reporter. $book->createReport([1, 2]); // Create a report on $book object with "report item id" of 1 and 2, and put user message of "some message on it", // and put current logged in user form default guard as reporter. $book->createReport([1, 2], 'some message'); // Create a report on $book object with "report item id" of 1 and 2, put user message of "some message on it", // and put current logged in user form 'api' guard as reporter. $book->createReport([1, 2], 'some message', 'api'); // Create a report on $book object with "report item id" of 1 and 2, put user message of "some message on it", // and put $user (3rd param) as reporter. $book->createReport([1, 2], 'some message', $user'); $book->reports(); // HasMany relation to reports of book. $book->reports; // Collection of book's reports. $book->isReported() // check if current logged in user form default guard has reported book. $book->isReported // check if current logged in user form default guard has reported book. $book->isReported('api') // check if current logged in user form 'api' guard has reported book. $book->isReported($user) // check if '$user' has reported book. $book->reportsCount; // return number of reports on $book. $book->reportsCount(); // return number of reports on $book.
Report objects
$report->assign(); // Assign current logged from default guard as admin of $report $report->assign('api'); // Assign current logged from 'api' guard as admin of $report $report->assign($user); // Assign $user as admin of $report // set resolved_at with current timestamp and assign current logged from default guard as admin of $report $report->resolve(); // set resolved_at with current timestamp and assign current logged from 'api' guard as admin of $report $report->resolve('api'); // set resolved_at with current timestamp and assign $user as admin of $report $report->resolve($user); // check if $report is resolved or not. $report->isResolved();
Credits
- Mohammad Nourinik - http://inpinapp.com
inpin/lara-report 适用场景与选型建议
inpin/lara-report 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 913 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「error」 「spam」 「report」 「trait」 「laravel」 「issue」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 inpin/lara-report 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inpin/lara-report 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 inpin/lara-report 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple captcha generator
reCAPTCHA library
Reportico Open Source PHP Report Designer
Client library for reCAPTCHA with proxy support, a free service that protects websites from spam and abuse.
Allow KoolReport to use twig template engine to render view
PHP Error Handler module that captures and displays all throwable errors in a given format, making debugging easier and more efficient
统计信息
- 总下载量: 913
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-03