PHPackages                             rezaghz/laravel-reports - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. rezaghz/laravel-reports

ActiveLibrary[Database &amp; ORM](/categories/database)

rezaghz/laravel-reports
=======================

Laravel reports package for implementing reports (eg: Spam,Violence,Child Abuse,illegal Drugs etc) on Eloquent models.

v1.0.0(3y ago)221895MITPHPPHP &gt;=7.0

Since Nov 7Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/rezaghz/laravel-reports)[ Packagist](https://packagist.org/packages/rezaghz/laravel-reports)[ Docs](https://rezaghz.com)[ Fund](https://yekpay.me/en/rezaghz)[ RSS](/packages/rezaghz-laravel-reports/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Laravel Reports
===============

[](#laravel-reports)

[![laravel-reports](https://user-images.githubusercontent.com/36597017/200645468-274bc278-f0fb-4430-a2f1-ebae4a6fa986.jpg)](https://user-images.githubusercontent.com/36597017/200645468-274bc278-f0fb-4430-a2f1-ebae4a6fa986.jpg)

Laravel reports package for implementing reports (eg: Spam,Violence,Child Abuse,illegal Drugs, etc.) on Eloquent models.

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 6.x, 7.x, 8.x, 9.x, 10.x, 11.x, or 12.x

Installation
------------

[](#installation)

Download package into the project using Composer.

```
$ composer require rezaghz/laravel-reports
```

### Registering package

[](#registering-package)

> Laravel 5.5 (or higher) uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

For Laravel 5.4 or earlier releases version include the service provider within `app/config/app.php`:

```
'providers' => [
    Rezaghz\Laravel\Reports\ReportsServiceProvider::class,
],
```

### Database Migration

[](#database-migration)

If you want to make changes in migrations, publish them to your application first.

```
$ php artisan vendor:publish --provider="Rezaghz\Laravel\Reports\ReportsServiceProvider" --tag=laravel-reports-migrations
```

Run database migrations.

```
$ php artisan migrate
```

Usage
-----

[](#usage)

### Prepare Reports (User) Model

[](#prepare-reports-user-model)

Use `Rezaghz\Laravel\Reports\Contracts\ReportsInterface` contract in model which will perform report behavior on reportable model and implement it and use `Rezaghz\Laravel\Reports\Traits\Reports` trait.

```
use Rezaghz\Laravel\Reports\Traits\Reports;
use Rezaghz\Laravel\Reports\Contracts\ReportsInterface;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements ReportsInterface
{
    use Reports;
}
```

### Prepare Reportable Model

[](#prepare-reportable-model)

Use `Rezaghz\Laravel\Reports\Contracts\ReportableInterface` contract in model which will get report behavior and implement it and use `Rezaghz\Laravel\Reports\Traits\Reportable` trait.

```
use Illuminate\Database\Eloquent\Model;
use Rezaghz\Laravel\Reports\Traits\Reportable;
use Rezaghz\Laravel\Reports\Contracts\ReportableInterface;

class Article extends Model implements ReportableInterface
{
    use Reportable;
}
```

Available Methods
-----------------

[](#available-methods)

### Report

[](#report)

```
$user->reportTo($article, 'spam');

$article->report('spam'); // current login user
$article->report('spam', $user);
```

### Remove Report

[](#remove-report)

Removing report of user from reportable model.

```
$user->removeReportFrom($article);

$article->removeReport(); // current login user
$article->removeReport($user);
```

### Toggle Report

[](#toggle-report)

The toggle report method will add a report to the model if the user has not reported. If a user has already reported, then it will replace the previous report with a new report. For example, if the user has reported 'spam' on the model. Now on toggles report to 'violence' then it will remove the 'spam' and stores the 'violence' report.

If a user has reported `spam` then on toggle report with `spam`. It will remove the report.

```
$user->toggleReportOn($article, 'spam');

$article->toggleReport('spam'); // current login user
$article->toggleReport('spam', $user);
```

### Boolean check if user reported on model

[](#boolean-check-if-user-reported-on-model)

```
$user->isReportedOn($article));

$article->is_reported; // current login user
$article->isReportBy(); // current login user
$article->isReportBy($user);
```

### Report summary on model

[](#report-summary-on-model)

```
$article->reportSummary();
$article->report_summary;

// example
$article->report_summary->toArray();
// output
/*
[
    "spam" => 5,
    "violence" => 2,
    "illegal_drugs" => 4,
    "child_abuse" => 1
]
*/
```

### Get collection of users who reported on model

[](#get-collection-of-users-who-reported-on-model)

```
$article->reportsBy();
```

### Scopes

[](#scopes)

Find all articles reported by user.

```
Article::whereReportedBy()->get(); // current login user

Article::whereReportedBy($user)->get();
Article::whereReportedBy($user->id)->get();
```

### Report on Model

[](#report-on-model)

```
// It will return the Report object that is reported by given user.
$article->reported($user);
$article->reported(); // current login user
$article->reported; // current login user

$user->reportedOn($article);
```

### Events

[](#events)

On each report added `\Rezaghz\Laravel\Reports\Events\OnReport` event is fired.

On each report removed `\Rezaghz\Laravel\Reports\Events\OnDeleteReport` event is fired.

Testing
-------

[](#testing)

Run the tests with:

```
$ composer test
```

Or run PHPUnit directly:

```
$ vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

### v2.0.0 (2025-01-08)

[](#v200-2025-01-08)

- **BREAKING**: Updated to support Laravel 12.x
- **BREAKING**: Requires PHP 8.2 or higher
- Updated migration to use modern Laravel 12 patterns
- Fixed method naming inconsistencies
- Improved type hints and return types
- Updated testing framework compatibility

### v1.0.0 (2023-09-28)

[](#v100-2023-09-28)

- Initial release
- Support for Laravel 6.x - 10.x
- Basic reporting functionality

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance41

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1286d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f177b9c1433b1dfd10a027026980f4304d9f8cea6cf7b3a7c2149345d3f47fe8?d=identicon)[rezaghz](/maintainers/rezaghz)

---

Top Contributors

[![rezaghz](https://avatars.githubusercontent.com/u/36597017?v=4)](https://github.com/rezaghz "rezaghz (13 commits)")[![BCleverly](https://avatars.githubusercontent.com/u/628574?v=4)](https://github.com/BCleverly "BCleverly (1 commits)")[![souzajluiz](https://avatars.githubusercontent.com/u/102811214?v=4)](https://github.com/souzajluiz "souzajluiz (1 commits)")

---

Tags

eloquentlaravellikeratereportreportsunlikelaraveleloquentreportRatelikeRatingstardislikeUnlikeemotion

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rezaghz-laravel-reports/health.svg)

```
[![Health](https://phpackages.com/badges/rezaghz-laravel-reports/health.svg)](https://phpackages.com/packages/rezaghz-laravel-reports)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[qirolab/laravel-reactions

Implement reactions (like, dislike, love, emotion etc) on Laravel Eloquent models.

19564.6k](/packages/qirolab-laravel-reactions)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[cybercog/laravel-ban

Laravel Ban simplify blocking and banning Eloquent models.

1.1k651.8k11](/packages/cybercog-laravel-ban)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
