pmochine / laravel-report
Laravel 5 可报告的多态 Eloquent 模型
3.2.0
2020-11-08 17:24 UTC
Requires
- php: >=7.2
- illuminate/database: ~5.4||~5.5||~5.6||~5.7||~5.8||~6.0||~7.0||~8.0
- illuminate/support: ~5.4||~5.5||~5.6||~5.7||~5.8||~6.0||~7.0||~8.0
Requires (Dev)
- graham-campbell/testbench: ^5.0
- mockery/mockery: ^1.0
- phpunit/phpunit: ^9.4.2
README
安装
使用 Composer 在项目的根目录中安装此包。
$ composer require pmochine/laravel-report
要开始,您需要发布供应商资源和迁移
php artisan vendor:publish --provider="Pmochine\Report\ReportServiceProvider" && php artisan migrate
用法
设置模型
<?php namespace App; use Pmochine\Report\Traits\HasReports; use Illuminate\Database\Eloquent\Model; class Post extends Model { use HasReports; }
示例
用户模型报告帖子模型
$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->conclusion;
获取报告模型的评判者(只有存在结论时才可用)
$report->judge(); // Just a shortcut for $report->conclusion->judge
获取一个包含所有曾经“评判”过某物的评判者的数组
Report::allJudges();
测试
$ phpunit
安全
如果您发现任何安全相关的问题,请不要给我发邮件。我害怕 😱。 avidofood@protonmail.com
致谢
现在是最棒的部分! 😍 这个包是基于