PHPackages                             phhung/orchid-tables - 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. phhung/orchid-tables

ActiveLibrary

phhung/orchid-tables
====================

An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.

v10.14.8.1(2y ago)114MITPHPPHP ^8.0|^8.1

Since Sep 19Pushed 2y agoCompare

[ Source](https://github.com/phhung1901/orchid-tables)[ Packagist](https://packagist.org/packages/phhung/orchid-tables)[ Docs](https://github.com/phhung1901/orchid-tables)[ RSS](/packages/phhung-orchid-tables/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

OrchidTables
============

[](#orchidtables)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cac140a45a5ca3526bf475027a4bae956a5deb9e71fc8d89c5483f12919a3d69/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c696e746162612f6f72636869642d7461626c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lintaba/orchid-tables)[![Total Downloads](https://camo.githubusercontent.com/8b21f6e0c32d913185a6c20640d777de3c94d028567d5698b71635f0b49a84a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c696e746162612f6f72636869642d7461626c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lintaba/orchid-tables)[![Build Status](https://camo.githubusercontent.com/62d32496a7ed8303d01f03300fe78e560d70d52774d87046612ce6fca51edfdc/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c696e746162612f6f72636869642d7461626c65732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/lintaba/orchid-tables)[![StyleCI](https://camo.githubusercontent.com/a264e6fde8ae824c1bf3d8193f47751f52e429d6dcd72adf34507d066f8a526e/68747470733a2f2f7374796c6563692e696f2f7265706f732f3435323934313336352f736869656c64)](https://styleci.io/repos/452941365)[![PHP Composer](https://github.com/lintaba/orchid-tables/actions/workflows/php.yml/badge.svg)](https://github.com/lintaba/orchid-tables/actions/workflows/php.yml)

An opinionated extension package for [Laravel Orchid](orchid) to extend its table handling capabilities, and some further useful helper methods.

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

[](#installation)

Via Composer

```
$ composer require lintaba/orchid-tables
```

Usage
-----

[](#usage)

This package adds the following new shiny things:

- [Checklist td](#TdChecklist) - Checklist for tables
- [TD/Field/Layout::can, canAll](#can) - permission-based visibility for fields, columns, layouts
- [Layout::html()](#layoutHtml) - raw html for layouts
- TD extensions:
    - [date](#td-date)
    - [num](#td-num)
    - [limit](#td-limit)
    - [bool](#td-bool)
    - [keyValues](#td-keyValues)
    - [link](#td-link)
    - [renderable](#td-renderable)
    - [rowClass](#td-rowClass)
    - [rowLink](#td-rowLink)
- [TableAdvanced](#tableAdvanced) - Formattable, clickable table rows
- [QuickExport](#QuickExport) - Export datatables within seconds

### Screen\\TdChecklist

[](#screentdchecklist)

Checklist with select-all support. Can select range by pressing `shift`.

[![](docs/tdChecklist.png)](docs/tdChecklist.png)

Usage:

```
use Lintaba\OrchidTables\Screen\TDChecklist;

class UserTable extends Table {
//...
    public function columns(): array
    {
        return [
            TDChecklist::make(),
            //...
            TD::make('id'),
        ];
    }
}
```

`TDChecklist::make($name = 'checkbox')`

`->checkboxSet(key,value)`

and almost everything available thats available on `TD`.

Without further configuration it sends the following:

```
checkbox[] = 1

```

The provided collection's items must have a `getKey():int|string` method, which provides the value for the checkbox.

By default the checklist belongs to the main form, which is linked to most of the action buttons, therefore having a `Button` within `Screen@commandBar()` will send the selection list too. However the modals are having their own forms, so it will not be included there. Currently only one form is supported. (Feel free to open a ticket if you need support for multiple forms/modals.)

Changing the form of the list to a modal:

```
class UserTable extends Table {
//...
    public function commandBar(): array {
        return [
            ModalToggle::make("my modal")->modal('myModal'),
        ];
    }
    public function columns(): array {
        return [
            TD::Checklist::make()->checkboxSet('form','screen-modal-form-myModal'),
        ];
    }
```

Redirecting back with error/success can keep the current selection:

```
class UserScreen extends Screen {
//...
    public function activateUsers(Request $request){
        Alert::message('Selected item count is still ' . count($request->get('checkbox', []) ) );
        $request->flash();
    }
```

###  Can mixins:

[](#-can-mixins)

These are mixed into most of the orchid's makeable and visible things.

- `TD`
- `Field`
- `LayoutFactory`

#### can(string\[\] $permissions...)

[](#canstring-permissions)

Hides the field if the current user has none of the listed permissions.

Shows only if a previous `canSee` didn't hide it, and if **any** of the listed permissions are given to the user.

#### canAll(string\[\] $permissions...)

[](#canallstring-permissions)

Hides the field if the current user has none of the listed permissions.

Shows only if a previous `canSee` didn't hide it, and if **all** of the listed permissions are given to the user.

> Both `can` and `canAll` internally usese `canSee`, so chaining another `canSee` after a `can` will invalidate the permission check.

> Using a non-existing permission throws an easily fixable exception during development mode, to help avoid bugs.

### Layout mixins:

[](#layout-mixins)

####  html

[](#-html)

```
html(string|callable $content): self
```

Makes a `Layout` component, that renders the provided html string (or the value of it, when its a closure.)

### Cell mixins:

[](#cell-mixins)

####  date

[](#-date)

```
date(bool $withHumanReadable = true, string $format = null): self
```

Formats a date string or carbon date to human readable. Format defaults to `config('orchid-tables.date_format')`, `config('app.date_format')`, or `Y?-m-d H:i`. (omits year if its the current year.)

####  num

[](#-num)

```
num(int $decimals = 0,
        string $suffix = null,
        string $decimalSeparator = ',',
        string $thousandsSeparator = DataHelpers::NBSP): self
```

Formats a numeric value to a more readable / convinient format.

- Sets the decimals
- May add a suffix, delimitered with a non-breakable space (nbsp), which guaranteed not to be broken to multiple lines.

*example:*

```
TD::make('size')->num(2,'m²')
```

####  limit

[](#-limit)

```
limit(int $max = 100, string $end = '...')
```

Keeps the text under the given maximum character count. If its longer, replaces the end with ... (or anything specified in `end`).

####  bool()

[](#-bool)

Shows a green tick, or a red cross, depending on if the column's value has a truthy or falsy value.

TruthyFalsy ####  keyValues()

[](#-keyvalues)

```
keyValues(int $maxDepth = 3)
```

Shows a key-value structure (using `dl/dt/dd`) of a complex object / array / json entry.

Limits max depth, by default to 3.

####  link($href, $segments = null)

[](#-linkhref-segments--null)

Makes a link/button to the target location. Both `$href` and `$segments` can be a closure, or a value.

Example:

```
// article: { user: { id: 42, first: "John", last: "Doe", __toString:"John Doe" } }
TD::make('user')->link(function(User $user){return route('user.show',$user->id)}),
//John Doe

TD::make('user')->link('user.create',['last','first'])
//Doe John
```

####  renderable()

[](#-renderable)

Tries to render a model, using one of the following:

- its value, when its a scalar or null
- as a `Personable` `Persona`
- `->presenter()` to get a `Personable` `Persona`
- value from `->display()`
- its `name`, `slug`, or `class@id` as last resort.

### Formatted exportable cells

[](#formatted-exportable-cells)

These helper methods are useful with formatted excel exports. By default its not activated, as it adds an extra overhead, which is usually not being used. To activate, you can either set it up in the configuration:

```
# config/orchid-tables.php
        'cell'   => Mixins\CellExportFormattableMixin::class,
```

or call the following:

```
\Lintaba\OrchidTables\Facades\OrchidTables::mixinTdExportFormattables();
```

Augmented methods:

- `date`
    - Formatted as date
- `num`
    - Formatted as the provided number format, but stored as a number.
- `keyValues`
    - Stored as json in the output

Furthermore the following helper methods are available:

\####notExportable($notExportable = true): self Sets a column to be non-exported.

> Its advised to set it on ie. action buttons.

\####setStyle($style): self

A callback that formats the given row, or the actual formatting. Can be called multiple times, and the result will be merged. Callback can either return with a phpexcel formatted array, or one (or multiple merged together) from the followings:

- `ExportStyles::FORMAT_NONE`
- `ExportStyles::FORMAT_TEXT`
- `ExportStyles::FORMAT_HUF`
- `ExportStyles::FORMAT_USD`
- `ExportStyles::FORMAT_EUR`
- `ExportStyles::FORMAT_PCS`
- `ExportStyles::FORMAT_DATE`
- `ExportStyles::FORMAT_DATETIME`
- `ExportStyles::FORMAT_TIME`
- `ExportStyles::FORMAT_BOLD`
- `ExportStyles::FORMAT_ITALIC`
- `ExportStyles::FORMAT_UNDERLINED`
- `ExportStyles::FORMAT_LEFT`
- `ExportStyles::FORMAT_RIGHT`
- `ExportStyles::FORMAT_CENTER`
- `ExportStyles::FORMAT_TOP`
- `ExportStyles::FORMAT_MIDDLE`
- `ExportStyles::FORMAT_BOTTOM`
- `ExportStyles::FORMAT_RED`
- `ExportStyles::FORMAT_GREEN`
- `ExportStyles::FORMAT_YELLOW`
- `ExportStyles::FORMAT_BLUE`
- `ExportStyles::FORMAT_BLACK`

\####exportRender(callable $callback): self

Sets the renderer method for excel. Input is the field's value. Must return with a `string` or `stringable`.

**Example:**

```
TD::make('name')->exportRender(function(string $value, User $entry, int $rowNum){
    return Str::upper($value).' #'.$entry->id.' (row-'.$rowNum.')';
})
```

### QuickExport

[](#quickexport)

Using `Lintaba\OrchidTables\Exports\QuickExport` its possible to set up data exports quickly, without creating extra classes, just by building on an already existing table.

**Quick export example:**

```
use Lintaba\OrchidTables\Exports\QuickExport;
use Orchid\Screen\Actions\Button;
use Orchid\Screen\Screen;

class UsersTableScreen extends Screen
{

    public function commandBar(): array
    {
        return [
            Button::make('export')->method('export')->rawClick(),
        ];
    }

    public function export(){
        $query = User::filters()->defaultSort('id', 'desc');
        return (new QuickExport($query, UserTable::class))->download('userExport.xlsx');
    }
//...
```

###  TableAdvanced

[](#-tableadvanced)

The extended table layout, `\Lintaba\OrchidTables\Screen\TableAdvanced` adds the following functionality:

#### rowClass($row)

[](#rowclassrow)

Calculates classlist based on a row. Useful for coloring a whole row.

#### rowLink($row)

[](#rowlinkrow)

Makes a row clickable.

**Example:**

```
use Lintaba\OrchidTables\Screen\TableAdvanced

class UserTable extends TableAdvanced
{

    public function rowClass(User $row)
    {
        return $row->active ? 'bg-success' : 'bg-danger';
    }

    public function rowLink(User $row)
    {
        return route('admin.users.show',$row);
    }
//...
```

Customization
-------------

[](#customization)

Run the following command to publish the configuration:

```
php artisan vendor:publish --tag="orchid-tables.config"
```

```
# /config/orchid-tables.php
use Lintaba\OrchidTables\Mixins;

return [
    'mixins' => [
        'can'    => Mixins\CanMixin::class,
        'cell'   => Mixins\CellMixin::class,
        'layout' => Mixins\LayoutMixin::class,
    ],

    'date_format' => null,
];
```

Extend or create your overwrites, based on the existing mixins, like `\Lintaba\OrchidTables\CellMixin`. You can turn on or off any of these mixins by setting their key to `null`.

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [contributing.md](contributing.md) and open tickets for details and a todolist.

Credits
-------

[](#credits)

- [Bálint Vass](https://github.com/lintaba)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% 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

Unknown

Total

1

Last Release

963d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/54b33da254e527950459ae8ef657d353226e274cf63e743d3785744e24fb22d6?d=identicon)[phhung1901](/maintainers/phhung1901)

---

Top Contributors

[![lintaba](https://avatars.githubusercontent.com/u/375078?v=4)](https://github.com/lintaba "lintaba (20 commits)")[![NguyenUoc98](https://avatars.githubusercontent.com/u/43318488?v=4)](https://github.com/NguyenUoc98 "NguyenUoc98 (2 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![phhung1901](https://avatars.githubusercontent.com/u/79549917?v=4)](https://github.com/phhung1901 "phhung1901 (1 commits)")

---

Tags

orchidorchid-platformlaravelOrchidTablesOrchid Platform

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/phhung-orchid-tables/health.svg)

```
[![Health](https://phpackages.com/badges/phhung-orchid-tables/health.svg)](https://phpackages.com/packages/phhung-orchid-tables)
```

###  Alternatives

[lintaba/orchid-tables

An opinionated extension package for Laravel Orchid to extend its table handling capabilities, and some further useful helper methods.

402.4k](/packages/lintaba-orchid-tables)[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[alexsabur/orchid-livewire

A Livewire macro for Orchid Platform

255.7k](/packages/alexsabur-orchid-livewire)

PHPackages © 2026

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