承接 alyakin/reporting 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alyakin/reporting

Composer 安装命令:

composer require alyakin/reporting

包简介

Flexible Laravel package for attaching user reports to any model. Useful for moderation, feedback, and auditing.

README 文档

README

Packagist Version Downloads Laravel 9+ PHP 8+ MIT License

PHPUnit Laravel Pint Larastan Larastan Level

Laravel Complaint & Note Manager is a package for managing complaints, notes, and similar entities in Laravel projects. It uses polymorphic relationships for integration with any models.

Ideal for social networks, e-commerce, and content moderation projects that require collecting and managing user complaints, reports, or note (use cases).

Features:

  • Polymorphic Relationships: Easy integration with different models.
  • Metadata: Ability to save additional data.
  • Automatic Deletion: Manage outdated records.
  • Customization: Configure through configuration files and migrations.

Table of Contents

  1. Laravel Complaint & Note Manager
  2. Installation
  3. Configuration
  4. Usage
  5. Automatic Deletion of Old Complaints
  6. Use cases
  7. Testing
  8. Want to Contribute?
  9. License

Installation

Requirements

  • PHP ^8.0
  • Laravel ^9.0, ^10.0, ^11.0

Step 1: Install via Composer

composer require alyakin/reporting

Step 2: Publish Configuration and Migrations

php artisan vendor:publish --provider="Alyakin\Reporting\ReportingServiceProvider"
php artisan migrate

Ensure that your database settings are correct before running migrations.

Configuration

After installing the module, the configuration file is available at config/reporting.php. If the file is missing, run the following command:

php artisan vendor:publish --provider="Alyakin\Reporting\ReportingServiceProvider" --tag=config

Basic Settings

Example configuration file content:

return [
    'report_model' => \Alyakin\Reporting\Models\Report::class,
    'soft_delete_days' => 30,
];

Customizing the Complaint Model

If you need to extend the default model, update the report_model parameter in the configuration:

'report_model' => \App\Models\CustomReport::class,

The model must extend Alyakin\Reporting\Models\Report:

namespace App\Models;

use Alyakin\Reporting\Models\Report;

class CustomReport extends Report
{
    // Your additional methods or fields
}

Usage

Adding the Reportable Trait

Add the Reportable trait to any model that should support complaints:

use Alyakin\Reporting\Traits\Reportable;

class Post extends Model
{
    use Reportable;
}

Creating a Complaint

Use the reports() relationship to create a complaint:

$post = Post::find(1);
$user = $request->user();

$report = $post->addReport([
    'reason' => 'Спам',
    'meta' => ['severity' => 'низкий'],
], $user->id);

Retrieving Complaints

Retrieve all complaints for a model:

$reports = $post->reports;

Retrieve the related model from a complaint:

$post = $report->reportable;

Deleting a Complaint

Delete a complaint using standard Eloquent methods:

$report->delete();

Automatic Deletion of Old Complaints

Old complaints are deleted based on the soft_delete_days parameter in the configuration (default is 30 days).

Scheduler Configuration

Add the following line to app/Console/Kernel.php:

$schedule->command('model:prune')->daily();

Manual Deletion

Run the cleanup process manually:

php artisan model:prune

Use Cases

Here are five different examples of how this package can be applied across various domains:

  1. Social Networks: Users can report posts or comments that violate guidelines...
  2. E-commerce Platforms: Customers can flag products or sellers...
  3. Content Management Systems (CMS): Readers can report offensive or incorrect content...
  4. Customer Support Systems: Users can submit complaints linked to their accounts or tickets...
  5. Educational Platforms: Students can report problems with course materials or instructors...

Testing

This package includes a test suite to ensure functionality works as expected. To run the tests:

composer test

PHPUnit

The package uses PHPUnit for feature and unit tests. You can run PHPUnit tests specifically with:

./vendor/bin/phpunit

Static Analysis

We use Larastan (PHPStan for Laravel) for static code analysis (with level 9):

./vendor/bin/phpstan analyse

Code Style

Laravel Pint is used for code style enforcement:

./vendor/bin/pint

Want to Contribute?

This package is open for community contributions!

You can:

  • Explore the open issues to see what's planned
  • Pick a task labeled good first issue or help wanted
  • Suggest a new feature or improvement by opening an issue
  • Fork the repository and submit a Pull Request

Contribution Requirements

When contributing to this package, please ensure:

  1. Code Style: All code must follow our style guidelines. Run Laravel Pint before submitting:

    ./vendor/bin/pint
  2. Static Analysis: Code must pass Larastan level 9 analysis:

    ./vendor/bin/phpstan analyse
  3. Test Coverage: All new features or bug fixes must include tests.

  4. Documentation: Update the README.md and other documentation to reflect any changes in functionality.

  5. Feature Branches: Create a feature branch for your changes and submit a pull request against the main branch.

Current Roadmap Highlights

  • Add support for Laravel-style events (e.g. ReportCreated, ReportDeleted)
  • Artisan command to purge old reports (reporting:purge)

We welcome contributions, feedback, and ideas! 😊

License

This package is distributed under the MIT License.

alyakin/reporting 适用场景与选型建议

alyakin/reporting 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Audit」 「report」 「laravel」 「feedback」 「moderation」 「complaints」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 alyakin/reporting 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alyakin/reporting 我们能提供哪些服务?
定制开发 / 二次开发

基于 alyakin/reporting 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 32
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-08