PHPackages                             advicepharmagroup/tablegenerator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. advicepharmagroup/tablegenerator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

advicepharmagroup/tablegenerator
================================

A table generator to be used with react js

1.2.0(1mo ago)1337MITPHPPHP ^8.1|^8.2|^8.3|^8.4

Since Dec 5Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/advicepharmagroup/laravel-tablegenerator)[ Packagist](https://packagist.org/packages/advicepharmagroup/tablegenerator)[ Docs](https://github.com/advicepharmagroup/tablegenerator)[ RSS](/packages/advicepharmagroup-tablegenerator/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (12)Versions (29)Used By (0)

Table generator
===============

[](#table-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f96d1848b02848f7427050b2c5dae7fd243a1a8f5db75a5c5fa1fa70e1477a75/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616476696365706861726d612f7461626c6567656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/advicepharma/tablegenerator)[![Total Downloads](https://camo.githubusercontent.com/193de894e821a2caa95f3eca738215e25b5aa7941d895106194166a5a6be735f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616476696365706861726d612f7461626c6567656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/advicepharma/tablegenerator)

A package to create a structured jason that should be consumed with a react component.

Requirements
------------

[](#requirements)

You have to install:

- spatie query builder ()

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require advicepharma/tablegenerator
```

Basic Usage
-----------

[](#basic-usage)

```
use Advicepharma\Tablegenerator\Tablegenerator;
use Advicepharma\Tablegenerator\Elements\Action;
use Advicepharma\Tablegenerator\Elements\Column;
use Advicepharma\Tablegenerator\Elements\ActionColumn;
use Spatie\QueryBuilder\QueryBuilder;

$users = QueryBuilder::for(App\Models\User::class);

$table = new Tablegenerator;
$table->query($users)
        ->paginate()
        ->addFilter()
        ->addSorts()
        ->table()
        ->addColumn(
            [
                (new Column)
                    ->field('id')
                    ->label('ID')
                    ->filtrable()
                    ->sortable(),

                (new Column)
                    ->field('name')
                    ->label('Name')
                    ->filtrable()
            ]
        );
```

Table creation command
----------------------

[](#table-creation-command)

`php artisan make:advtable TableName --model=Model`

like

`php artisan make:advtable UserTable --model=User`

Column object
-------------

[](#column-object)

`label()` column label (header) `field()` display the field in `QueryBuilder` object `filtrable()` set the column filtrable `sortable()` set the column sortable

Adding column
-------------

[](#adding-column)

Adding column accpets array of `Column` or `Column` object.

```
$table->->table()
        ->addColumn(
            [
                (new Column)
                    ->field('name')
                    ->label('Name'),
                (new Column)
                    ->field('email')
                    ->label('Email')
            ]
        )
```

or:

```
$table->->table()
        ->addColumn(
            (new Column)
                ->field('name')
                ->filterKey('name')
                ->label('Name')
                ->filtrable()
                ->sortable()
        )
```

Action column
-------------

[](#action-column)

Action column are used to render actions in the table. Default action are edit and delete:

```
(new ActionColumn)
    ->label('')
    ->addAction(
        (new Action)
            ->type(Action::ACTION_EDIT)
            ->properties(
                [
                    'link_to' => '/account/users/#id#'
                ]
            )
    )
    ->addAction(
        (new Action)
            ->type(Action::ACTION_DELETE)
            ->properties(
                [
                    'confirm' => true,
                    'confirm_message' => 'Do you really want to delete this user?',
                    'link_to' => route('user.destroy', '#id#', false)
                ]
            )
    )
```

`type` can be whatever you want: this two are the default one.

`properties` can contains all the properties that are going to be consumed by frontend

Pagination
----------

[](#pagination)

Pagination is super easy: you have to add `->paginate()` to create default pagination structure. If you want, you can specify the pagesize passing an integer value `->paginate(100)`

Api resource
------------

[](#api-resource)

If you want to use ApiResource feature, you can add it with

```
$table->->table()
    ->withResource(YourResource::class)
```

Relationship column
-------------------

[](#relationship-column)

If you are working with a QueryBuilder with relationship, like:

```
QueryBuilder::for(App\Models\Post::class)->with('user');
```

Al you need to do is to specify the colum field with dot notation:

```
(new Column)->field('user.name')->label('User Name')
```

If you want to filter a related field, you need to add `filterKey('user.name')` (or whatever table.field value you want to search)

**Unforturnately sorting a relation field is not yet supported**

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Giacomo Garavaglia](https://github.com/giagara)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance92

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 64.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~63 days

Recently: every ~311 days

Total

27

Last Release

38d ago

PHP version history (3 changes)1.0.0PHP ^7.4|^8.0

1.1.0PHP ^8.1|^8.2|^8.3

1.2.0PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/135609569?v=4)[Advice Pharma Group s.r.l.](/maintainers/advicepharmagroup)[@advicepharmagroup](https://github.com/advicepharmagroup)

---

Top Contributors

[![giagara](https://avatars.githubusercontent.com/u/79515022?v=4)](https://github.com/giagara "giagara (37 commits)")[![advicepharma](https://avatars.githubusercontent.com/u/95569845?v=4)](https://github.com/advicepharma "advicepharma (13 commits)")[![flaviomaniscalco](https://avatars.githubusercontent.com/u/135622969?v=4)](https://github.com/flaviomaniscalco "flaviomaniscalco (6 commits)")[![MarcelloBossi](https://avatars.githubusercontent.com/u/126185596?v=4)](https://github.com/MarcelloBossi "MarcelloBossi (1 commits)")

---

Tags

advicepharmatablegenerator

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/advicepharmagroup-tablegenerator/health.svg)

```
[![Health](https://phpackages.com/badges/advicepharmagroup-tablegenerator/health.svg)](https://phpackages.com/packages/advicepharmagroup-tablegenerator)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

244.6M137](/packages/illuminate-cookie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
