PHP code example of dynamik-dev / modman

1. Go to this page and download the library: Download dynamik-dev/modman 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/ */

    

dynamik-dev / modman example snippets




namespace App\Models;

use Dynamik\Modman\Concerns\Reportable as ReportableTrait;
use Dynamik\Modman\Contracts\Reportable;
use Dynamik\Modman\Support\ModerationContent;
use Illuminate\Database\Eloquent\Model;

class Post extends Model implements Reportable
{
    use ReportableTrait;

    public function toModerationContent(): ModerationContent
    {
        return ModerationContent::make()->withText($this->body);
    }
}

$post = Post::find($postId);
$report = $post->report(reporter: auth()->user(), reason: 'Spam');



namespace App\Listeners;

use Dynamik\Modman\Events\ReportResolved;
use Dynamik\Modman\Support\VerdictKind;

class HideRejectedContent
{
    public function handle(ReportResolved $event): void
    {
        if ($event->outcome === VerdictKind::Reject) {
            $event->report->reportable?->update(['hidden_at' => now()]);
        }
    }
}

// config/modman.php
'routes' => [
    'enabled' => true,                    // set false to skip route registration entirely
    'middleware' => ['api', 'auth:sanctum'], // override to match your guard stack
],

use Dynamik\Modman\Models\Report;
use Illuminate\Support\Facades\Gate;
use App\Models\User;

Gate::define('modman.view', fn (User $user, Report $report) => $user->is_moderator);
Gate::define('modman.resolve', fn (User $user, Report $report) => $user->is_moderator);
Gate::define('modman.reopen', fn (User $user, Report $report) => $user->is_moderator);
bash
composer vendor:publish --tag=modman-migrations
php artisan vendor:publish --tag=modman-config
php artisan migrate
bash
php artisan vendor:publish --tag=modman-resources