cakmalik/livewire-generic-table
Composer 安装命令:
composer require cakmalik/livewire-generic-table
包简介
A reusable and customizable generic table component for Livewire 3.
README 文档
README
A flexible, Volt-friendly, and fully customizable table component for Laravel Livewire v3.
Designed for reusable admin tables with sorting, searching, actions, pagination, and custom column formatting.
🚀 Features
- Works with both Livewire and Livewire Volt
- Fully customizable column configuration array
- Searchable and sortable columns
- Badge formats with dynamic colors & labels
- Image, badge, datetime, link, and custom renderers
- Row actions with event emission
- Pagination with configurable per‑page options
- Easy integration into any Laravel app or package
📦 Installation
Install via Composer:
composer require your-vendor/generic-table
If using Laravel < 10.21, publish views:
php artisan vendor:publish --tag=livewire-generic-table-views
🧩 Usage
In Blade
<livewire:generic-table :model="'App\\Models\\Post'" :columns="$columns" :queryParams="['keyword' => request('keyword')]" defaultSortField="created_at" defaultSortDirection="desc" />
In Volt
Because Volt does not allow nested arrays inside state, you must use a computed property:
#[Computed] public function columns(): array { return [ [ 'label' => 'Title', 'field' => 'title', 'sortable' => true, 'searchable' => true, ], [ 'label' => 'Status', 'field' => 'status', 'format' => 'badge', 'badge' => [ 'colors' => [ 'draft' => 'bg-gray-100 text-gray-700', 'published' => 'bg-green-100 text-green-800', ], 'labels' => [ 'draft' => 'Draft', 'published' => 'Published', ], 'default' => 'bg-gray-200 text-gray-900', 'default_label' => 'Unknown', ], ], ]; }
Then use it:
<livewire:generic-table :model="$this->modelName" :columns="$this->columns" :queryParams="[ 'keyword' => request('keyword') ]" />
🛠 Column Options
Each column supports:
| Key | Description |
|---|---|
label |
Column header text |
field |
Column data field (supports nested relation.field) |
sortable |
Enable sorting |
searchable |
Enable keyword searching |
format |
text, image, badge, datetime, custom |
badge |
Configuration for badge colors & labels |
actions |
Row action buttons |
Example with actions
[
'label' => 'Actions',
'field' => 'actions',
'actions' => [
[
'event' => 'editAction',
'icon' => 'pencil',
'color' => 'indigo',
'variant' => 'primary',
],
[
'event' => 'deleteAction',
'icon' => 'trash',
'color' => 'red',
'variant' => 'danger',
],
],
],
📡 Events
Your component may listen to row action events:
#[On('editAction')] public function edit($id) { // handle edit }
🎨 Custom Styling
You may override the view:
php artisan vendor:publish --tag=generic-table-views
Then edit:
resources/views/vendor/generic-table/generic-table.blade.php
🤝 Contributing
Pull requests are welcome!
If you want to improve functionality, fix bugs, or extend features—feel free to contribute.
📜 License
This package is open-sourced under the MIT License.
cakmalik/livewire-generic-table 适用场景与选型建议
cakmalik/livewire-generic-table 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「component」 「grid」 「table」 「datatables」 「livewire」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cakmalik/livewire-generic-table 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cakmalik/livewire-generic-table 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cakmalik/livewire-generic-table 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.
FSi DataSource Component
Plug-ins for DataTables
A component that allows creating responsive HTML tables or lists from data object
Adjacency List’ed Closure Table database design pattern implementation for Laravel. Includes restore of tree
TYPO3 extension providing content elements powered by gridelements and bootstrap. Available elements: container, columns, tabs, accordion, tile unit and card.
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-08