PHPackages                             llama-laravel/table-view - 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. [Templating &amp; Views](/categories/templating)
4. /
5. llama-laravel/table-view

ActiveLibrary[Templating &amp; Views](/categories/templating)

llama-laravel/table-view
========================

Laravel 5 Package for easily displaying table views for Eloquent Collections with search and sort functionality built in.

110PHP

Since Dec 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/xuanhoa88/laravel-datatable)[ Packagist](https://packagist.org/packages/llama-laravel/table-view)[ RSS](/packages/llama-laravel-table-view/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

laravel-table-view
==================

[](#laravel-table-view)

Laravel 5 Package for easily displaying table views for Eloquent Collections with search and sort functionality built in.

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

[](#installation)

Update your `composer.json` file to include this package as a dependency

```
"llama-laravel/table-view": "dev-master"
```

Register the TableView service provider by adding it to the providers array in the `config/app.php` file.

```
'providers' => array(
    Llama\TableView\TableViewServiceProvider::class
)
```

If you want you can alias the TableView facade by adding it to the aliases array in the `config/app.php` file.

```
'aliases' => array(
        'TableView' => Llama\TableView\Facades\TableViewFacade::class,
)
```

Configuration
=============

[](#configuration)

Copy the vendor file views and assets into your project by running

```
php artisan vendor:publish

```

This will add multiple styles and one script to public/vendor/table-view The plugin depends on jQuery and v1.9.1 will be included under public/vendor/table-view - Bootstrap CSS v3.3.2 - Font Awesome v4.3.0 - jQuery v1.9.1

Usage
=====

[](#usage)

Initialize the table view by passing in an instance of \\Illuminate\\Eloquent\\Builder or simply the class name of the model for the tableview

```
	$users = User::select('id', 'name', 'email', 'created_at');

	$usersTableView = TableView::collection( $users )
	// or $usersTableView = TableView::collection( \App\User::class )
```

Adding Column to the tableview

```
	addColumn($usersTableView
		// you can pass in the title for the column, and the Eloquent\Model property name
		->addColumn('Email', 'email')

		// Add a colon after the Eloquent\Model property name along with sort and/or search to enable these options
		->addColumn('Name', 'name:sort,search')

		// Set the default sorting property with
		->addColumn('Name', 'name:sort*,search')	// Sorted Ascending by default or specify
		->addColumn('Name', 'name:sort*:asc')
		->addColumn('Name', 'name:sort*:desc')

		// Custom column values are created by passing an array with the Eloquent\Model property name as the key
		//  and a closure function
		->addColumn('Joined At', ['created_at:sort*' => function ($user)
		{
			return $user->created_at->diffForHumans();
		}])

		// OR
		->addColumn(function ($user)
		{
			return '';
		})
		->addColumn('Email', 'email:sort,search')
		->addColumn(function ($user)
		{
			return 'View';
		});
```

Removing Column to the tableview

```
	$usersTableView->removeColumn('Email', 'Name');
```

Custom column values

```
	addColumn($usersTableView
		// You can pass in an array for the column's row value with the Eloquent\Model property name as the key
		//  and a closure function
		->addColumn('Joined At', ['created_at:sort*' => function ($user)
		{
			return $user->created_at->diffForHumans();
		}])
		// OR if sorting and searching is unnecessary, simply pass in the Closure instead of the array
		->addColumn('Image', function ($user)
		{
			return '';
		})
		// Using modify, we can specify the column of the cell we want to modify, and the function should return an array of attributes to be added to the cell.
		->modifyColumn('Image', ['created_at:sort*' => function ($user)
		{
			return 'something';
		}]);
}]);
```

Columns without titles

```
	addColumn($usersTableView
		// Just leave the column title out if you don't want to use it
		->addColumn(function ($user)
		{
			return '';
		});
```

Finally, build the TableView and pass it to the view

```
	$usersTableView = $usersTableView->build();

	return view('test', [
		'usersTableView' => $usersTableView
	]);
```

All together with chaining

```
Route::get('/', function(\Illuminate\Http\Request $request)
{
	$users = User::select('id', 'name', 'email', 'created_at');

	$usersTableView = TableView::collection( $users, 'Administrator' )
		->addColumn(function ($user)
		{
			return '';
		})
		->addColumn('Name', 'name:sort,search')
		->addColumn('Email', 'email:sort,search')
		->addColumn('Joined At', ['created_at:sort*' => function ($user)
		{
			return $user->created_at->diffForHumans();
		}])
		->addColumn(function ($user)
		{
			return 'View';
		})
		->build();

	return view('test', [
		'usersTableView' => $usersTableView
	]);
});
```

Front End
=========

[](#front-end)

Include stylesheets for Bootstrap and Font Awesome - Bootstrap CSS v3.3.2 and Font Awesome v4.3.0 are included in the vendor

```

```

Include the tablview in your view, referencing the variable name given to it

```
@include('table-view::container', ['tableView' => $usersTableView])
```

Middleware Cookie Storage
=========================

[](#middleware-cookie-storage)

Selected options for the tableview are easily added to cookie storage with built-in Middleware.

Sort options and limits per page are each added to permanent storage. At any point, a user returning to the tableview will see these options filled with the same values that he/she selected in his/her most recent session.

The search query and page number are temporarily stored during the user's current session. With this, a user could visit something  with the tableview listing articles. When a user views a specific article like , any link back to  will show the tableview with its most recent page number and search query.

All you have to do:

Edit app/Http/Kernel.php, adding a reference to the Middleware

```
    /**
     * The application's route middleware.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,

        // Laravel TableView Middleware
        'table-view.storage' => \Llama\TableView\Middleware\TableViewCookieStorage::class,
    ];
```

Then add it to the route containing the tableview

```
    Route::get('/', ['middleware' => 'table-view.storage', function () {
```

That's it!
==========

[](#thats-it)

It's particular but in just a few lines you have a dynamic table view with powerful functionality. Feel free to customize the tableview and element partial views. Additional themes and styles coming soon.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8601be70d0d3d5a02c55b5aca4b1ee0d762370b77b95bdb8bce9f6a68a7d0827?d=identicon)[xuanhoa88](/maintainers/xuanhoa88)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/llama-laravel-table-view/health.svg)

```
[![Health](https://phpackages.com/badges/llama-laravel-table-view/health.svg)](https://phpackages.com/packages/llama-laravel-table-view)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

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