PHP code example of phoenix1331 / laravel-jev-moderation

1. Go to this page and download the library: Download phoenix1331/laravel-jev-moderation 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/ */

    

phoenix1331 / laravel-jev-moderation example snippets


use Phoenix1331\JevModeration\Attributes\Moderate;
use Phoenix1331\JevModeration\Concerns\Moderatable;

#[Moderate(fields: ['title', 'body'], policy: 'community')]
class ForumPost extends Model
{
    use Moderatable;
}

$post->moderationStatus();      // ModerationStatus, or null if never checked
$post->isFlagged();             // waiting for a human
$post->isBlocked();             // blocked, or rejected by a moderator

ForumPost::query()->get();               // visible content only
ForumPost::onlyFlagged()->get();         // the review queue
ForumPost::withoutModeration()->get();   // everything

$post->flagForReview('reported by user', $reporter);
$post->approve($moderator, 'false positive');
$post->reject($moderator, 'confirmed spam');
$post->reject($moderator, 'harassment, not spam', category: 'harassment');

use Phoenix1331\JevModeration\Facades\JevModeration;

if (JevModeration::classify($message, 'chat')->blocked()) {
    return;
}

'actions' => [
    'spam' => ['review_above' => 0.50, 'block_above' => 0.90],
    'harassment' => ['review_above' => 0.40, 'block_above' => 0.95],
    'personal_data' => ['review_above' => 0.40],
],
'uncertain_below' => 0.30,

use Phoenix1331\JevModeration\Facades\JevModeration;

JevModeration::fake()->classifyAs('spam', 1.0, ['spam' => 1.0]);

$post = ForumPost::query()->create(['title' => 'Cheap watches', 'body' => 'Buy now']);

expect($post->isBlocked())->toBeTrue();
JevModeration::fake()->assertClassifiedTimes(1);
bash
php artisan jev-moderation:ping