Reportable Polymorphic Eloquent Models for Laravel 5

Reportable Polymorphic Eloquent Models for Laravel 5


Latest Version
Total Downloads
Software License

Laravel Reportable

This package will allow you to add a full report system into your Laravel application.


First, pull in the package through Composer.

composer require ghanem/reportable

And then include the service provider within app/config/app.php.

'providers' => [

At last you need to publish and run the migration.

php artisan vendor:publish


php artisan migrate

Setup a Model


namespace App;

use GhanemReportableContractsReportable;
use GhanemReportableTraitsReportable as ReportableTrait;
use IlluminateDatabaseEloquentModel;

class Post extends Model implements Reportable
    use ReportableTrait;


The User Model reports the Post Model


namespace AppHttpControllers;

use AppHttpControllersController;

use AppPost;
use Auth;

class PostController extends Controller
    public function makeReport()
        $post = Post::find(1);
        $user = Auth::user();
            'reason' => str_random(10),
            'meta' => ['some more optional data, can be notes or something'],
        ], $user);

Create a conclusion for a Report and add the User Model as “judge” (useful to later see who or what came to this conclusion)

    '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);

Get the conclusion for the Report Model


Get the judge for the Report Model (only available if there is a conclusion)

$report->judge(); // Just a shortcut for $report->conclusion->judge

Get an array with all Judges that have ever “judged” something



Add a Comment

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *