pmochine/laravel-report

Laravel 5 可报告的多态 Eloquent 模型

3.2.0 2020-11-08 17:24 UTC

This package is auto-updated.

Last update: 2024-09-09 01:58:35 UTC


README

PHP from Packagist Latest Version

安装

使用 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

致谢

现在是最棒的部分! 😍 这个包是基于

许可

MIT © Brian Faust