PHP code example of roundly-consulting / reports-for-laravel

1. Go to this page and download the library: Download roundly-consulting/reports-for-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

roundly-consulting / reports-for-laravel example snippets


use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Reports\Contracts\Reportable;
use RoundlyConsulting\Reports\Contracts\Reporter;
use RoundlyConsulting\Reports\Traits\GivesReports;
use RoundlyConsulting\Reports\Traits\HasReports;

class User extends Model implements Reporter
{
    use GivesReports;
}

class Post extends Model implements Reportable
{
    use HasReports;
}

use RoundlyConsulting\Reports\Enums\Reason;
use RoundlyConsulting\Reports\Facades\Reports;

$report = Reports::report($post)
    ->by($user)
    ->for(Reason::Abuse)                       // a typed, validated reason
    ->because('This post violates the community guidelines.')
    ->create();                                // a second report by $user throws DuplicateReportException

Reports::review($report);                      // pending → in review
Reports::resolve($report, by: $moderator, note: 'Removed the post.');

$post->reportsCount();                         // 1
Post::query()->mostReported()->get();          // the most-reported posts first
bash
composer vendor:publish --tag="reports-migrations"
php artisan vendor:publish --tag="approvals-migrations"
php artisan migrate