Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

ploi-deploy/roadmap

527 stars
2 code files
View ploi-deploy/roadmap on GitHub

app/Observers/CommentObserver.php

Open in GitHub
use App\Models\Comment;
use Xetaio\Mentions\Parser\MentionParser;
 
class CommentObserver
{
public function created(Comment $comment)
{
$parser = new MentionParser($comment, [
'regex_replacement' => [
'{character}' => '@',
'{pattern}' => '[A-Za-z0-9_-]',
'{rules}' => '{4,20}'
],
]);
 
$content = $parser->parse($comment->content);
 
$comment->updateQuietly([
'content' => $content,
]);
}
 
public function deleting(Comment $comment)
{
$comment->mentions()->delete();
}
}

app/Providers/EventServiceProvider.php

Open in GitHub
use App\Models\Comment;
use App\Observers\CommentObserver;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
 
class EventServiceProvider extends ServiceProvider
{
//
protected $observers = [
//
Comment::class => [CommentObserver::class],
];
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.