承接 centrex/livewire-comments 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

centrex/livewire-comments

最新稳定版本:v2.0.1

Composer 安装命令:

composer require centrex/livewire-comments

包简介

Manage comments with livewire in laravel

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Real-time polymorphic comment threads built with Livewire. Supports nested replies, likes (by authenticated user or by IP/user-agent for guests), Markdown rendering, @mention linking, and soft-deletes.

Installation

composer require centrex/livewire-comments
php artisan vendor:publish --tag="livewire-comments-migrations"
php artisan migrate

Usage

1. Add the Livewire component to any Blade view

<livewire:comments :model="$post" />

The $model can be any Eloquent model — comments are stored polymorphically.

2. Add the HasUserAvatar trait to your User model (optional)

use Centrex\LivewireComments\Traits\HasUserAvatar;

class User extends Authenticatable
{
    use HasUserAvatar;
    // Provides avatar() → Gravatar URL based on email
}

3. Comment model

use Centrex\LivewireComments\Models\Comment;

// All top-level comments for a model
Comment::parent()->where('commentable_type', Post::class)
    ->where('commentable_id', $post->id)
    ->with('children', 'user')
    ->get();

// Nested replies
$comment->children;    // ordered oldest-first
$comment->isParent();  // true if no parent_id

// Likes
$comment->likes_count;
$comment->isLiked();
$comment->removeLike();

4. Comment presenter

$comment->presenter()->markdownBody();       // HtmlString (Markdown rendered)
$comment->presenter()->relativeCreatedAt();  // "2 hours ago"
$comment->presenter()->replaceUserMentions($text); // links @mentions to user profiles

Config

php artisan vendor:publish --tag="livewire-comments-config"
// config/commentify.php
'users_route_prefix' => 'users',   // used for @mention links: /users/{username}

Testing

composer test        # full suite
composer test:unit   # pest only
composer test:types  # phpstan
composer lint        # pint

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2.47k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固