PHPackages                             aginev/datagrid - 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. aginev/datagrid

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

aginev/datagrid
===============

Datagrid Package for Laravel v5+

3.0.0(4y ago)4828.7k↓50%17[1 PRs](https://github.com/aginev/datagrid/pulls)MITPHPPHP ^7.2|^8.0CI failing

Since Jun 25Pushed 2y ago6 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (22)Used By (0)

Datagrid For Laravel 5+
=======================

[](#datagrid-for-laravel-5)

Package that easily converts collection of models to a datagrid table. The main goal of the package is to build for you a table with sorting and filters per column. You are defining the grid structure in your controller, pass the datagrid to the view and show it there. This will give you a really clean views, just a single line to show the table + filters + sorting + pagination. Keep in mind that filtering and sorting the data is up to you!

Features
--------

[](#features)

- Composer installable
- PSR4 auto-loading
- Has filters row
- Has columns sort order
- Easily can add action column with edit/delete/whatever links
- Ability to modify cell data via closure function
- Bootstrap friendly
- Each column has data attributes based on a column data key

Requires
--------

[](#requires)

Build to be used with Laravel only!

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

[](#installation)

Require package at your composer.json file like so

```
{
    "require": {
        "aginev/datagrid": "3"
    }
}
```

Tell composer to update your dependencies

```
composer update
```

Or in terminal

```
composer require aginev/datagrid
```

HOWTO
-----

[](#howto)

Let's consider that we have users and user roles (roles) table at our system.

### Users table

[](#users-table)

**id:** primary key

**role\_id:** foreign key to roles table primary key

**email:** user email added used as username

**first\_name:** user first name

**last\_name:** user last name

**password:** hashed password

**created\_at:** when it's created

**updated\_at:** when is the latest update

### Roles Table

[](#roles-table)

**id:** primary key

**title:** Role title e.g. Administrators Access

**created\_at:** when it's created

**updated\_at:** when is the latest update

We need a table with all the users data, their roles, edit and delete links at the last column at the table, filters and sort links at the very top, pagination at the very bottom.

```
