PHPackages                             startupwrench/laratables - 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. [API Development](/categories/api)
4. /
5. startupwrench/laratables

ActiveLibrary[API Development](/categories/api)

startupwrench/laratables
========================

A package to easily transform your Eloquent models into JSON to be used by Datatables 1.10+.

151PHP

Since Jan 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/startupwrench/laratables)[ Packagist](https://packagist.org/packages/startupwrench/laratables)[ RSS](/packages/startupwrench-laratables/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laratables
==========

[](#laratables)

A Laravel package to convert Eloquent queries into JSON output to work with Datatables. This is a fork of:  to fix some issues, and errors for a production app, feel free to use it, but no warranties expressed or implied.

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

[](#installation)

Add the following to your `composer.json` file.

```
require {
	"startupwrench/laratables": "dev-master"
}

```

Run `composer install`.

Open `app/config/app.php` and add:

`Startupwrench\Laratables\LaratablesServiceProvider::class,`

Also add the alias:

`'Laratables'      => Startupwrench\Laratables\LaratablesFacade::class,`

And publish the configuration from the command line:

`php artisan vendor:publish`

Usage
-----

[](#usage)

Use the model function to set the main Eloquent model.

`$dt = Laratables::model('NewsItem');`

Set any optional relationship you want to use.

`$dt->with('user', 'category');`

Set the columns you want to retrieve. Columns of relationship models are written as .

`$dt->columns([ 'id', 'title', 'user.first_name', 'newsCategory.name', 'created_at', 'updated_at' ]);`

Wrap some optional HTML around a column. Parameters can be passed by wrapping them in curly braces.

```
$dt->wrapHtml('title', '', '');
$dt->wrapHtml('user.first_name', '', '');

```

Additional columns can also be added manually.

`$dt->addColumn('delete','Delete');`

Get the JSON output.

`$response = $dt->make();`

### Chaining

[](#chaining)

The property setters all return the L4EloquentDatatables object so you can easily chain commands. The aforementioned example can be rewritten as following.

```
Laratables::model('NewsItem')
	->with('user', 'newsCategory')
	->columns([ 'id', 'title', 'user.first_name', 'newsCategory.name', 'created_at', 'updated_at' ])
	->wrapHtml('title', '', '')
	->wrapHtml('user.first_name', '', '')
	->addRawColumn('delete','Delete')
	->make();

```

Limitations
-----------

[](#limitations)

This is a fairly simple package with very few features. It was made for personal use but I figured other people might have a use for it. The most important limitation in my opinion is that you cannot sort columns of relationship models. If anyone is interested in writing support for this, you are more than welcome to do so.

###  Health Score

22

—

LowBetter than 23% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/93200a7b28a43c505e27f5e94fe3ca99f3469b26a741b4cd0978cc5dd2d05a32?d=identicon)[patrickcurl](/maintainers/patrickcurl)

---

Top Contributors

[![patrickcurl](https://avatars.githubusercontent.com/u/1470061?v=4)](https://github.com/patrickcurl "patrickcurl (14 commits)")[![yuri-moens](https://avatars.githubusercontent.com/u/1128153?v=4)](https://github.com/yuri-moens "yuri-moens (8 commits)")

### Embed Badge

![Health badge](/badges/startupwrench-laratables/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M33](/packages/facebook-php-business-sdk)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M95](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

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