几天内即可获得 Laravel 代码审查方面的专家指导

Drop in comments for Filament with Commentions

发布日期 经过

Drop in comments for Filament with Commentions image

Building commenting systems from scratch is one of those features that sounds simple until you actually start implementing it. You need comment models, user mentions, reactions, permissions, real-time updates, and a clean UI that fits your admin panel. What starts as "just add comments" quickly becomes a complex feature that takes weeks to build properly.

If you're using Filament for your admin panel, you already know the incredible power of this framework. Filament has revolutionized Laravel development by providing beautiful, full-stack components that accelerate development while maintaining the elegance and flexibility Laravel developers love. With the recent release of Filament v4 (officially stable as of August 2025), the framework has reached new heights with significant performance improvements, unified schemas, and enhanced flexibility that make building sophisticated admin interfaces even more effortless.

Now, with Commentions - fully compatible with both Filament v3 and the cutting-edge v4 release - you can extend that same elegance to commenting systems. As Filament's official development agency partner, Kirschbaum Development has created a drop-in commenting solution that feels like it was built into Filament from day one.

Instead of building all of this from scratch, wouldn't it be cool if you could just do something like this?

// In your Filament InfoList
CommentsEntry :: 制作 '评论'
-> mentionables fn 模型 $record) => 用户 :: 全部 ())

Or add it as a simple table action:

// In your Filament table
-> recordActions ([
CommentsAction :: 制作 ()
-> mentionables 用户 :: 全部 ())
])

This is exactly what Commentions brings to your Filament application - a complete commenting system built with deep understanding of Filament's patterns and philosophy.

Why we built Commentions

As Filament's official development agency partner, Kirschbaum Development is dedicated to elevating the experience of working with Filament. With Dan Harrin as a member of our team and our commitment to supporting Filament's growth, we're uniquely positioned to understand what developers need most.

Filament has transformed how we approach Laravel development. Its component-driven architecture, intuitive APIs, and stunning design system have made building complex admin panels not just faster, but genuinely enjoyable. The recent stable release of Filament v4 has taken this even further, delivering impressive performance improvements (up to 3x faster for large datasets), unified schemas that seamlessly combine forms, infolists, and layout components, and support for custom table data that opens up entirely new possibilities for dynamic interfaces.

Through our work on large, complex Filament projects - leveraging everything from Filament's powerful table builders to its flexible form components - we found ourselves building similar commenting features repeatedly across client applications. Each time, we'd create comment models, build mention systems, handle permissions, and design interfaces that perfectly matched Filament's aesthetic excellence. We realized we were solving the same problem over and over again - and if we were facing this challenge, so were countless other developers in the thriving Filament community.

Our partnership with Filament means we're not just building packages - we're crafting solutions that seamlessly extend Filament's philosophy of elegant, powerful components. With full compatibility for both Filament v3 and the groundbreaking v4 release, Commentions embraces the framework's evolution while maintaining the simplicity and power that makes Filament so exceptional. Whether you're leveraging v4's new unified schemas or sticking with the proven patterns of v3, Commentions adapts to provide the same exceptional experience.

入门

Installation is straightforward - just require the package and publish the migrations:

作曲家 要求 kirschbaum-development/commentions
php 工匠 供应商:发布 --标签= "commentions-migrations"

Next, implement the required interfaces on your models:

// User model
使用 Kirschbaum\Commentions\Contracts\Commenter ;
班级 用户 延伸 模型 实现 评论者
{
// Your existing user model
}
// Any model you want to add comments to
使用 Kirschbaum\Commentions\HasComments ;
使用 Kirschbaum\Commentions\Contracts\Commentable ;
班级 项目 延伸 模型 实现 可评论
{
使用 HasComments ;
}

That's it for the setup. Your models are now ready to support comments.

Multiple ways to add comments

One of Filament's greatest strengths is its flexibility - the framework adapts to your workflow rather than forcing you into rigid patterns. Commentions embraces this philosophy by offering multiple integration options that work seamlessly with Filament's component system.

In InfoLists (recommended)

Leveraging Filament's powerful InfoList components, the cleanest approach is adding comments directly to your resource views:

Infolists\Components\Section :: 制作 'Comments'
-> 模式 ([
CommentsEntry :: 制作 '评论'
-> mentionables fn 模型 $record) => 用户 :: 全部 ())
]),

As table actions

Filament's table builder is incredibly versatile, and with v4's enhanced performance and support for custom data, it's become even more powerful. Commentions integrates beautifully for quick commenting directly from your table views. The package automatically detects your Filament version and uses the appropriate action format:

// Filament v4 (latest)
-> recordActions ([
CommentsAction :: 制作 ()
-> mentionables 用户 :: 全部 ())
])
// Filament v3 (still supported)
-> 行动 ([
CommentsTableAction :: 制作 ()
-> mentionables 用户 :: 全部 ())
])

As header actions

Perfect for dedicated comment management, taking advantage of Filament's consistent action patterns:

受保护 功能 getHeaderActions () : 大批
{
返回 [
CommentsAction :: 制作 (),
];
}

Smart mentions and events

One of Commentions' most powerful features is its mention system. When users mention someone in a comment using @username, the package automatically dispatches events you can hook into:

// Listen for mentions
使用 Kirschbaum\Commentions\Events\UserWasMentionedEvent ;
班级 SendUserMentionedNotification 实现 应该排队
{
民众 功能 处理 UserWasMentionedEvent $event) : 空白
{
$事件 -> 用户 -> 通知
新的 UserMentionedInCommentNotification (事件) -> comment)
(英文):
}
}

The package also dispatches events for new comments and reactions, giving you complete control over notifications and integrations.

Real-time updates with polling

Modern users expect real-time updates, and Filament's thoughtful architecture makes this effortless to implement. With v4's performance optimizations and partial rendering capabilities, real-time features are more efficient than ever. Commentions leverages Filament's built-in polling capabilities to deliver live comment updates:

CommentsEntry :: 制作 '评论'
-> poll '10s' // Poll every 10 seconds
-> mentionables 用户 :: 全部 ())

This integration showcases what makes Filament exceptional - complex functionality becomes simple configuration. The polling works seamlessly with Filament's lifecycle and, with v4's enhanced performance optimizations, runs more efficiently than ever. Comments refresh automatically without requiring page refreshes or complex JavaScript, while v4's partial rendering ensures minimal resource usage.

Advanced customization

Custom comment models

Need additional fields or logic? Extend the base Comment model:

班级 CustomComment 延伸 \Kirschbaum\Commentions\ 评论
{
受保护 $可填充 = [ '身体' , 'author_id' , 'commentable_id' , 'commentable_type' , '优先事项' ];
}

Then update your config:

// config/commentions.php
'comment' => [
'模型' => \App\Models\CustomComment ::班级 ,
],

Flexible permissions

The package includes sensible defaults for permissions, but you can override them completely:

班级 CommentPolicy 延伸 CommentionsPolicy
{
民众 功能 创造 评论者 $用户) : 布尔值
{
返回 $用户 -> 'create-comments' (英文):
}
民众 功能 更新 ($user, 评论 $comment) : 布尔值
{
返回 $用户 -> ID === 评论 -> 作者 ID || $用户 -> 管理员 ();
}
民众 功能 删除 ($user, 评论 $comment) : 布尔值
{
返回 $用户 -> ID === 评论 -> 作者 ID || $用户 -> 管理员 ();
}
}

Custom display names and avatars

Filament's commitment to beautiful, consistent interfaces extends to how users are represented, and v4's unified schemas make component integration even more seamless. Control how users appear in comments by implementing Filament's standard interfaces:

使用 Filament\Models\Contracts\HasName ;
使用 Filament\Models\Contracts\HasAvatar ;
班级 用户 延伸 模型 实现 评论者 , HasName , HasAvatar
{
民众 功能 getFilamentName () : 细绳
{
返回 $this -> 全名 ?? $this -> 电子邮件;
}
民众 功能 getFilamentAvatarUrl () : ?细绳
{
返回 $this -> avatar_url;
}
}

This approach demonstrates Filament's excellent design philosophy - consistent interfaces that work across the entire ecosystem.

Beyond comments: activity streams

Sometimes you want to show more than just user comments. Commentions supports "renderable comments" - custom items that appear in the comment stream:

民众 功能 getComments () : 收藏
{
// Get status changes
$statusHistory = $this -> statusHistory () -> 得到 () -> 地图
fn StatusHistory $history) => 新的 RenderableComment
ID : $history -> ID,
authorName : $history -> 用户 -> 姓名,
身体 : 打印 'Status changed from %s to %s' , $history -> old_status, $history -> new_status),
创建于 : $history -> 创建于,
(英文):
// Merge with actual comments
评论 = $this -> 评论 () -> 最新的 () -> '作者' -> 得到 ();
返回 $statusHistory -> 合并 (评论) -> 按降序排序 'createdAt' (英文):
}

This creates a unified activity stream showing both comments and system events.

Real-world impact

The difference Commentions makes becomes clear when you compare implementation approaches. This comparison also highlights why Filament has become so beloved in the Laravel community, especially with the recent v4 release bringing even more power and performance:

Without Commentions (traditional approach)

Building a commenting system from scratch requires handling multiple complex pieces:

  • Multiple database tables and migrations for comments, mentions, and reactions

  • Custom Livewire components that match Filament's sophisticated styling

  • Manual mention parsing and validation logic

  • Permission systems scattered across controllers and policies

  • Custom CSS to achieve Filament's beautiful, consistent aesthetic

  • Event dispatching infrastructure for notifications and integrations

  • Real-time update handling with WebSockets or polling mechanisms

  • Form builders that integrate seamlessly with Filament's patterns

  • Responsive design that works across Filament's breakpoints

  • Testing suites for all the custom functionality

With Commentions + Filament's power

CommentsEntry :: 制作 '评论'
-> mentionables 用户 :: 全部 ())
-> poll '30s'

This transformation exemplifies what makes Filament extraordinary - it turns complex requirements into elegant, readable code. With v4's performance improvements and unified schemas, this elegance comes with even better performance and flexibility. Commentions extends this philosophy, providing enterprise-grade commenting functionality through Filament's intuitive component system.

Embracing Filament's excellence

Commentions embodies both the Laravel philosophy of making complex things simple and Filament's commitment to beautiful, intuitive interfaces. As developers who have witnessed Filament transform from an innovative idea into an essential tool for Laravel development, we're continually amazed by its impact on our productivity and code quality. The recent stable release of Filament v4 represents a major milestone, bringing substantial performance improvements, unified schemas, and enhanced flexibility that push the boundaries of what's possible with admin interfaces.

Filament's component-driven architecture, thoughtful APIs, and attention to detail have set a new standard for admin panel development. With v4's 3x performance improvements for large datasets, seamless integration of forms and infolists through unified schemas, and support for custom table data, the framework has evolved to handle even the most demanding applications while maintaining its signature elegance.

The package handles the hard parts - mention parsing, event dispatching, permission checking, and UI consistency - while giving you hooks to customize behavior for your specific needs. Every component follows Filament's conventions, every style matches Filament's aesthetic excellence, and every interaction feels natural within the framework. With full support for both Filament v3 and v4, you can confidently upgrade your Filament installation knowing that Commentions will continue to work seamlessly.

Our partnership with Filament ensures that Commentions isn't just another package - it's a first-class citizen in the Filament ecosystem. Whether you're building a project management tool, a content management system, or any application where users need to collaborate through comments, Commentions provides the foundation you need without compromising the elegance that makes Filament special.

Give it a try in your next Filament project. Your users will appreciate the familiar, polished commenting experience that matches Filament's high standards, and your development team will appreciate the time saved on a feature that "just works" - built by developers who live and breathe Filament every day, with deep appreciation for the framework that has revolutionized Laravel development.

Luis Dalmolin photo

Luis is CTO at Kirschbaum with 15+ years building complex applications. A Laravel expert since v4, he also specializes in React, Vue, JavaScript, and AWS/DevOps, and actively contributes to open source.

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
了解软科技

以每小时 20 美元的价格聘请具备人工智能专业知识的 Laravel 开发人员。48 小时内即可开始工作。

访问 Acquaint Softtech
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
几天内即可获得 Laravel 代码审查徽标的专家指导

几天内即可获得 Laravel 代码审查方面的专家指导

专家级代码审查!两位拥有 10 年以上 Laravel 开发经验的开发者将为您提供清晰、实用的反馈,帮助团队构建更优质的应用程序。

几天内即可获得 Laravel 代码审查方面的专家指导
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
MongoDB 徽标

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB
Drop in comments for Filament with Commentions image

Drop in comments for Filament with Commentions

阅读文章
Laravel Starter Kits Now Include Toast Notifications image

Laravel Starter Kits Now Include Toast Notifications

阅读文章
Ship AI with Laravel: Stop Your AI Agent from Guessing image

Ship AI with Laravel: Stop Your AI Agent from Guessing

阅读文章
Laravel Cloud Adds Path Blocking to Prevent Bots From Waking Hibernated Apps image

Laravel Cloud Adds Path Blocking to Prevent Bots From Waking Hibernated Apps

阅读文章
Making Laravel MongoDB Operations Idempotent: Safe Retries for Financial Transactions image

Making Laravel MongoDB Operations Idempotent: Safe Retries for Financial Transactions

阅读文章
FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0 image

FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0

阅读文章