Package Data | |
---|---|
Maintainer Username: | ghanem |
Maintainer Contact: | dungnh@gmail.com (Dzung Nguyen) |
Package Create Date: | 2015-10-23 |
Package Last Update: | 2021-01-24 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:21:48 |
Package Statistics | |
---|---|
Total Downloads: | 7,505 |
Monthly Downloads: | 4 |
Daily Downloads: | 1 |
Total Stars: | 32 |
Total Watchers: | 4 |
Total Forks: | 8 |
Total Open Issues: | 2 |
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
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();