hassanhelfi/tabavel 问题修复 & 功能扩展

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

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

hassanhelfi/tabavel

Composer 安装命令:

composer require hassanhelfi/tabavel

包简介

Low-code dynamic tables for Laravel. We build the base (filtering, sorting, pagination, search) — you design the rows.

README 文档

README

Latest Version on Packagist PHP Version Total Downloads License

We build the base — you design the table.

Tabavel gives you filtering, sorting, pagination, and search out of the box.
You decide how much control you want:

Mode You write Best for
Default Nothing Quick tables, admin panels
Custom Rows Only <tr> rows When you need images, badges, custom buttons
Full Custom Entire table HTML Complete design freedom

Install

composer require hassanhelfi/tabavel

Publish config (optional):

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

Controller (Same for All Modes)

use HassanHelfi\Tabavel\Services\TableBuilder;
use Illuminate\Support\Facades\DB;

public function index(Request $request)
{
    $query = DB::table('products')
        ->select(['id', 'name', 'price', 'category', 'active', 'created_at']);

    $table = TableBuilder::make($query)
        ->columns([
            'name'     => ['type' => 'text', 'operators' => ['=', 'like']],
            'price'    => ['type' => 'text', 'operators' => ['=', '>', '<']],
            'category' => [
                'type'    => 'select',
                'options' => ['electronics' => 'Electronics', 'clothing' => 'Clothing'],
            ],
            'created_at' => ['type' => 'date'],
        ])
        ->searchable(['name', 'category'])
        ->sortable(['id', 'name', 'price', 'created_at'])
        ->apply($request);

    return view('products.index', ['table' => $table]);
}

Pagination Methods

Choose your pagination strategy in the controller:

// Simple pagination (default, fastest)
$table = TableBuilder::make($query)->simplePaginate()->apply($request);

// Full pagination with page numbers
$table = TableBuilder::make($query)->paginate()->apply($request);

// Cursor pagination (best for large datasets)
$table = TableBuilder::make($query)->cursorPaginate()->apply($request);

Mode 1: Default (Auto-Render)

Zero effort. The table renders all columns automatically.

<x-tabavel-table :table="$table" />

That's it. Filters, sorting, pagination — all included.

Mode 2: Custom Rows

You write only the <tr> rows. Headers, filters, pagination are still automatic.
Use this when you need images, badges, custom buttons, or special formatting.

<x-tabavel-table :table="$table" custom-rows show-actions>
    @foreach($table->get() as $product)
        <tr>
            <td>{{ $product->id }}</td>
            <td>
                <img src="/uploads/{{ $product->image }}" width="50" height="50"/>
            </td>
            <td style="width:100px;">{{ $product->name }}</td>
            <td>{{ number_format($product->price) }} $</td>
            <td>{{ $product->category }}</td>
            <td>
                @if($product->active)
                    <span class="badge bg-success">Active</span>
                @else
                    <span class="badge bg-danger">Inactive</span>
                @endif
            </td>
            <td>
                <a href="/products/{{ $product->id }}/edit" class="btn btn-sm btn-primary">
                    Edit
                </a>
            </td>
        </tr>
    @endforeach
</x-tabavel-table>

Mode 3: Full Custom

Don't use our views at all. Build your own table from scratch:

<input type="text" name="search" value="{{ request('search') }}">

<table class="my-custom-table">
    <thead>
        <tr>
            @foreach($table->getColumns() as $col)
                <th>{{ $col['label'] }}</th>
            @endforeach
        </tr>
    </thead>
    <tbody>
        @foreach($table->get() as $row)
            <tr>
                {{-- Design however you want --}}
                <td>{{ $row->name }}</td>
                <td>{{ $row->price }}</td>
            </tr>
        @endforeach
    </tbody>
</table>

{{ $table->get()->links() }}

Component Props

Prop Type Default Description
table TableBuilder null The TableBuilder instance
id string 'tabavel-table' HTML id for the table element
action string current URL Form action URL for filters
custom-rows bool false Enable custom row mode
show-actions bool false Show the "Actions" column
searchable bool auto-detected Show global search input
pagination-view string auto-detected Custom pagination view

Column Configuration

->columns([
    // Text filter with operators
    'name' => [
        'type'      => 'text',
        'label'     => 'Product Name',
        'operators' => ['=', '!=', 'like', 'like%'],
    ],

    // Select dropdown filter
    'status' => [
        'type'    => 'select',
        'options' => ['active' => 'Active', 'inactive' => 'Inactive'],
    ],

    // Date range filter (from/to)
    'created_at' => [
        'type' => 'date',
    ],

    // Custom filter logic
    'is_verified' => [
        'custom_filter' => function ($query, $operator, $value) {
            $value === 'yes'
                ? $query->whereNotNull('email_verified_at')
                : $query->whereNull('email_verified_at');
        },
    ],
])

Works With Eloquent

$table = TableBuilder::make(User::query()->select([...]))
    ->columns([...])
    ->apply($request);

Publish & Customize Views

php artisan vendor:publish --tag=tabavel-views

Then edit resources/views/vendor/tabavel/bootstrap-5/table.blade.php.

License

MIT

hassanhelfi/tabavel 适用场景与选型建议

hassanhelfi/tabavel 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「pagination」 「filter」 「sort」 「laravel」 「table」 「datatable」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hassanhelfi/tabavel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hassanhelfi/tabavel 我们能提供哪些服务?
定制开发 / 二次开发

基于 hassanhelfi/tabavel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-20