serhiikorniienko/laravel-reportify

Simple Laravel package for content reporting and moderation

dev-main 2025-02-22 17:26 UTC

This package is not auto-updated.

Last update: 2025-03-30 11:15:15 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Simple, yet powerful package for content reporting and moderation in Laravel applications. Add a Reportable trait to your models and you're ready to go.

Installation

You can install the package via composer:

composer require serhiikorniienko/laravel-reportify

You can simply run install command to publish config, migrations and migrate the database:

php artisan reportify:install

Alternatively, you can publish the migration and config file separately:

php artisan vendor:publish --tag="reportify-migrations"
php artisan migrate

And a config file:

php artisan vendor:publish --tag="reportify-config"

Configuration

Basic configuration is stored in config/reportify.php file. You can change the default values there.

global_threshold - the number of reports required to mark a content as inappropriate for everyone.

return [
    'global_threshold' => 3,
];

Usage

Add the Reportable trait to get started

use SerhiiKorniienko\Reportify\Reportable;

class MyModel extends Model
{
    // this trait adds the ability to report the model
    use Reportable;
}

Report your model using the report method

    $model->report()
        ->withReporter($user)
        ->withReason('This is inappropriate content')
        ->withStatus('pending')
        ->create();

Check if the model should be available to a user

    $model->visibleFor($user);

Currently, reportable model would not be visible for a user who has reported it. Also, it would not be visible for all users if the number of reports exceeds the global threshold.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.