PHP code example of blackpig-creatif / replique

1. Go to this page and download the library: Download blackpig-creatif/replique 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/ */

    

blackpig-creatif / replique example snippets


use BlackpigCreatif\Replique\RepliquePlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            RepliquePlugin::make(),
        ]);
}

RepliquePlugin::make()
    ->navigationGroup('Moderation')   // default: 'Comments'
    ->withDashboardWidget(),          // enable the pending-comments stats widget

use BlackpigCreatif\Replique\Attributes\Commentable;
use BlackpigCreatif\Replique\Concerns\HasComments;

#[Commentable(label: 'Blog Post')]
class Post extends Model
{
    use HasComments;
}

// config/replique.php
'commentable_models' => [
    \Some\Package\Article::class => 'Article',
],

// config/replique.php

return [

    // Anonymous commenting
    'allow_anonymous' => true,
    '1,

    // Text processing: plain | escaped_html | markdown
    'text_mode' => 'escaped_html',

    // Moderation: hold all comments pending approval before display
    '=> 'created_at',  // created_at | reaction_count

    // Pagination
    'per_page' => 20,

    // Strip prompt-injection patterns from submitted text
    'sanitise_injection' => true,

    'user_model'   => \App\Models\User::class,
    'table_prefix' => 'replique_',

    'filament_navigation_group' => 'Comments',

    // Manual registry supplement (see "Making a Model Commentable")
    'commentable_models' => [],

    'notifications' => [
        'on_new_comment'      => false,
        'on_approval_

// config/replique.php
'allow_anonymous' => true,
'

$post->comment('Nice article!', email: '[email protected]', name: 'A Reader');

// config/replique.php
'reaction_types' => ['like', 'dislike'],  // default
'reaction_types' => ['heart'],            // single toggle reaction
'reaction_types' => [],                   // disable entirely

$comment->react('like');               // toggle (adds if absent, removes if present)
$comment->reactionCount('like');       // int
$comment->reactionSummary();           // ['like' => 5, 'dislike' => 1]

$icons = [
    'like'   => ['outline' => '<path .../>', 'solid' => '<path .../>'],
    'dislike' => [...],
    'fire'   => [
        'outline' => '<path stroke-linecap="round" stroke-linejoin="round" d="..." />',
        'solid'   => '<path d="..." />',
    ],
];

// Authenticated user (auto-resolved from Auth::user())
$post->comment('Great read.');

// Specific user
$post->comment('Great read.', $user);

// Anonymous
$post->comment('Great read.', email: '[email protected]', name: 'Anonymous');

// Reply to an existing comment
$post->comment('I agree!', parentId: $comment->id);

// Override text mode
use BlackpigCreatif\Replique\Enums\TextMode;

$post->comment('**Bold claim.**', textMode: TextMode::Markdown);

$post->comments;                          // all comments (MorphMany)
$post->comments()->approved()->get();
$post->comments()->topLevel()->get();     // excludes replies
$post->comments()->pending()->get();

use BlackpigCreatif\Replique\Filament\RelationManagers\CommentsRelationManager;

public static function getRelations(): array
{
    return [
        CommentsRelationManager::class,
    ];
}

RepliquePlugin::make()->withDashboardWidget()

$comment->approve();
$comment->reject();
$comment->markAsSpam();

use BlackpigCreatif\Replique\Facades\Replique;

Replique::blockIp('1.2.3.4', reason: 'Persistent spammer');
Replique::isBlocked('1.2.3.4'); // bool

'notifications' => [
    'on_new_comment'       => true,
    'on_approval_

class Post extends Model
{
    use HasComments;

    public function notifyOnComment(): ?User
    {
        return $this->author; // notify whoever authored the post
    }
}

// config/replique.php
'notifications' => [
    'on_new_comment' => true,
    'notifiable_resolver' => fn ($commentable) => $commentable->owner,
],
css
@source '../../../../vendor/blackpig-creatif/replique/resources/**/*.blade.php';
bash
php artisan vendor:publish --tag="replique-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="replique-config"
bash
php artisan vendor:publish --tag="replique-views"
bash
php artisan replique:discover
bash
php artisan vendor:publish --tag="replique-views"
bash
# Refresh the commentable model registry cache
php artisan replique:discover