PHPackages                             sukohi/datatable-resource - 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. sukohi/datatable-resource

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

sukohi/datatable-resource
=========================

A Laravel package that provides data for Datatable which is jQuery plugin with pagination.

1.0.0(6y ago)03MITPHP

Since May 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/SUKOHI/DatatableResource)[ Packagist](https://packagist.org/packages/sukohi/datatable-resource)[ RSS](/packages/sukohi-datatable-resource/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

DatatableResource
=================

[](#datatableresource)

A Laravel package that provides resource data for Datatable which is jQuery plugin with pagination.

This package is for [Datatable](https://datatables.net/) and maintained under Laravel 6.x.

Installation
============

[](#installation)

```
composer require sukohi/datatable-resource:1.*

```

Usage
=====

[](#usage)

Basic usage
-----------

[](#basic-usage)

```
// in Route

Route::get('item_resource', function(){

    $query = \App\Item::query();

    // Of course you can add any methods here like `where()`, `orderBy()` and even `with()`.

    return new DatatableResource($query);

});

```

Now you can get JSON data that Datatable needs.

with additional values
----------------------

[](#with-additional-values)

```
return new DatatableResource($query, [
    'key_1' => 'value_1',
    'key_2' => 'value_2',
    'key_3' => 'value_3',
]);

```

Trait
=====

[](#trait)

This package contains `DatatableResourceTrait` that provides kind of useful methods.

In order to use them, set `DatatableResourceTrait` into your Model as follows.

```
use Sukohi\DatatableResource\Traits\DatatableResourceTrait;

class class Item extends Model
{
    use DatatableResourceTrait;

```

hasDatatableSearch()
--------------------

[](#hasdatatablesearch)

Check if current access has search parameters.

```
if($this->hasDatatableSearch()) {

    // Do something...

}

```

getDatatableSearchKeywords()
----------------------------

[](#getdatatablesearchkeywords)

You can get search keywords that `Datatable` submitted.

```
$keywords = $this->getDatatableSearchKeywords();

foreach($keywords as $keyword) {

    // Do someting...

}

```

hasDatatableSort()
------------------

[](#hasdatatablesort)

Check if current access has sort parameters.

```
if($this->hasDatatableSort()) {

    // Do something...

}

```

getDatatableSort()
------------------

[](#getdatatablesort)

You can get sort parameters that `Datatable` submitted.

```
$order_by = $this->getDatatableSort();

// Usage
$column = $order_by->column;
$direction = $order_by->direction;

```

License
=======

[](#license)

This package is licensed under the MIT License.

Copyright 2020 Sukohi Kuhoh

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

2193d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2980d59b309d45df3f2e6e51b1d336614da063240b8f76f873f287cd745ec5db?d=identicon)[Sukohi](/maintainers/Sukohi)

---

Top Contributors

[![SUKOHI](https://avatars.githubusercontent.com/u/5362394?v=4)](https://github.com/SUKOHI "SUKOHI (2 commits)")

### Embed Badge

![Health badge](/badges/sukohi-datatable-resource/health.svg)

```
[![Health](https://phpackages.com/badges/sukohi-datatable-resource/health.svg)](https://phpackages.com/packages/sukohi-datatable-resource)
```

###  Alternatives

[barryvdh/laravel-ide-helper

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

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

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

The Illuminate Pagination package.

10532.5M862](/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)

PHPackages © 2026

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