Laravel Grid
, (*1)
Laravel Grid is a package that helps you display table data. I could not find
package that would satisfy my needs so I decided to write one. Now I've been successfully using it in my two projects.
I hope you will enjoy it., (*2)
Example:, (*3)
```php
namespace App\Http\Controllers;, (*4)
use Boduch\Grid\Order;
use Boduch\Grid\Source\EloquentSource;, (*5)
class UsersController extends Controller
{
public function index()
{
$grid = app('grid.builder')
->createBuilder()
->setDefaultOrder(new Order('id', 'desc'))
->addColumn('id', [
'sortable' => true
])
->addColumn('name')
->addColumn('email')
->addColumn('created_at')
->setSource(new EloquentSource(new \App\Models\User()));, (*6)
return view('users')->with('grid', $grid);
}
}
````, (*7)
Features, (*8)
- Pagination
- Filtering
- Highly customizable
- Simple usage
- Different data source (Eloquent model, collection, array)
Installation
Requirements, (*9)
- PHP >= 7.0
- Laravel >= 5.2
Installation steps, (*10)
- run
composer require adam-boduch/laravel-grid
- open file
config/app.php
- add
Boduch\Grid\GridServiceProvider::class
into providers
array
Getting started
To keep your controllers clean, it's highly recommended to keep your grid classes as a separate php file., (*11)
Cookbook
Using twig
@todo, (*12)
Laravel Grid and repository pattern
@todo, (*13)
Laravel Grid and presentation pattern
@todo, (*14)
Table cell modification
@todo, (*15)
Different column name and filter name
@todo, (*16)