epigra / reportable
用于 Laravel 5 的 reportable 多态 Eloquent 模型
此包的官方仓库似乎已不存在,因此该包已被冻结。
1.0.1
2020-04-08 00:23 UTC
Requires
- php: ^7.2.5
- illuminate/database: ^5.8 || ^6.0 || ^7.0
- illuminate/support: ^5.8 || ^6.0 || ^7.0
Requires (Dev)
- orchestra/testbench: ^3.8 || ^4.0 || ^5.0
- phpunit/phpunit: ^8.0 || ^9.0
- predis/predis: ^1.1
This package is auto-updated.
Last update: 2020-09-01 17:04:40 UTC
README
安装
使用 Composer 在项目的根目录中要求此包。
$ composer require epigra/reportable
要开始,您需要发布供应商资产并进行迁移
php artisan vendor:publish --provider="Epigra\Reportable\ReportableServiceProvider" && php artisan migrate
使用方法
设置一个模型
<?php namespace App; use Epigra\Reportable\HasReports; use Illuminate\Database\Eloquent\Model; class Post extends Model { use HasReports; }
示例
User 模型报告 Post 模型
$post->report([ 'reason' => \Str::random(10), 'meta' => ['some more optional data, can be notes or something'], ], $user);
为报告创建结论并将用户模型作为“法官”添加(有助于稍后查看谁或什么得出了这个结论)
$report->conclude([ 'conclusion' => 'Your report was valid. Thanks! We\'ve taken action and removed the entry.', 'action_taken' => 'Record has been deleted.', // This is optional but can be useful to see what happend to the record 'meta' => ['some more optional data, can be notes or something'], ], $user);
获取 Report 模型的结论
$report->conclusion;
获取 Report 模型的法官(仅当有结论时可用)
$report->judge(); // Just a shortcut for $report->conclusion->judge
获取所有曾经“评判”过东西的法官的数组
Report::allJudges();
获取未评判的报告(没有结论的报告)
Report::unjudged(); // returns query builder.
更改用户报告者模型
Set your user model in the config('auth.providers.users.model');
测试
$ phpunit
安全
如果您在此包中发现安全漏洞,请提交一个问题。所有安全漏洞都将得到及时解决。
致谢
该项目归功于 Brian Faust 以及所有 贡献者。
许可
Mozilla 公共许可证版本 2.0 (MPL-2.0)。