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
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
- Laravel Complaint & Note Manager
- Installation
- Configuration
- Usage
- Automatic Deletion of Old Complaints
- Use cases
- Testing
- Want to Contribute?
- 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:
- Social Networks: Users can report posts or comments that violate guidelines...
- E-commerce Platforms: Customers can flag products or sellers...
- Content Management Systems (CMS): Readers can report offensive or incorrect content...
- Customer Support Systems: Users can submit complaints linked to their accounts or tickets...
- 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 issueorhelp 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:
-
Code Style: All code must follow our style guidelines. Run Laravel Pint before submitting:
./vendor/bin/pint
-
Static Analysis: Code must pass Larastan level 9 analysis:
./vendor/bin/phpstan analyse
-
Test Coverage: All new features or bug fixes must include tests.
-
Documentation: Update the README.md and other documentation to reflect any changes in functionality.
-
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alyakin/reporting 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Log adding/updating/deleting of elements
Doctrine ORM provider for the auditor audit-log library.
Reportico Open Source PHP Report Designer
PB Web Media Audit Bundle for Symfony
Allow KoolReport to use twig template engine to render view
Pure PHP library to read JRXML files made with 'JasperSoft Studio' and generate reports in PDF
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-08