Reportable Polymorphic Eloquent Models for Laravel 6, 7, 8, 9, 10, 11 & 12
ghanem/reportable is a Laravel package for reportable polymorphic eloquent models for laravel 6, 7, 8, 9, 10, 11 & 12.
It currently has 33 GitHub stars and 7.583 downloads on Packagist (latest version v1.2).
Install it with composer require ghanem/reportable.
Discover more Laravel packages by ghanem
or browse all Laravel packages to compare alternatives.
Last updated
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' => [
Ghanem\Reportable\ReportableServiceProvider::class
];
At last you need to publish and run the migration.
php artisan vendor:publish --provider="Ghanem\Reportable\ReportableServiceProvider"
and
php artisan migrate
<?php
namespace App;
use Ghanem\Reportable\Contracts\Reportable;
use Ghanem\Reportable\Traits\Reportable as ReportableTrait;
use Illuminate\Database\Eloquent\Model;
class Post extends Model implements Reportable
{
use ReportableTrait;
}
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Post;
use Auth;
class PostController extends Controller
{
public function makeReport()
{
$post = Post::find(1);
$user = Auth::user();
$post->report([
'reason' => str_random(10),
'meta' => ['some more optional data, can be notes or something'],
], $user);
}
$report->conclude([
'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);
$report->conclusion;
$report->judge(); // Just a shortcut for $report->conclusion->judge
Report::allJudges();