webudvikleren/laravel-commentable 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

webudvikleren/laravel-commentable

最新稳定版本:v1.0.4

Composer 安装命令:

composer require webudvikleren/laravel-commentable

包简介

Easily add comments to any Laravel model

README 文档

README

Latest Version on Packagist Total Downloads License

Laravel Commentable adds a simple way to allow comments on any Eloquent model.

Features

  • Add comments to any Eloquent model
  • Polymorphic relationship
  • User tracking (via user_id)
  • Publishable migration and config
  • Clean and extensible architecture

Installation

composer require webudvikleren/laravel-commentable

Publish the migration (optional)

php artisan vendor:publish --tag=commentable-config
php artisan migrate

If you don’t publish the migration, Laravel will auto-load it from the package.

Usage

Step 1: Add the trait to your model

use Webudvikleren\Commentable\Traits\Commentable;

class Post extends Model
{
    use Commentable;
}

Step 2: Add comments

$post = Post::find(1);

$post->comments()->create([
    'body' => 'This is a comment.',
    'user_id' => auth()->id(),
]);

Step 3: Access comments

foreach ($post->comments as $comment) {
    echo $comment->body;
}

Comment Model

By default, comments are stored in the comments table and use the provided Webudvikleren\Commentable\Models\Comment model.

You can override this in your app if needed by extending the model and binding it in a service provider.

Configuration

You can publish the config file to override defaults:

php artisan vendor:publish --tag=commentable-config

Example config/commentable.php (coming soon).

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固