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.1.0(1y ago)0221MITPHPPHP ^8.1|^8.2|^8.3

Since Dec 5Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (6)Versions (28)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

41

—

FairBetter than 89% of packages

Maintenance50

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 67.3% 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 ~50 days

Recently: every ~215 days

Total

26

Last Release

368d ago

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

1.1.0PHP ^8.1|^8.2|^8.3

### 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 (4 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

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M210](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M858](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)

PHPackages © 2026

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