PHP code example of adam-boduch / laravel-grid

1. Go to this page and download the library: Download adam-boduch/laravel-grid library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adam-boduch / laravel-grid example snippets


namespace App\Http\Controllers;

use Boduch\Grid\Order;
use Boduch\Grid\Source\EloquentSource;

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()));
            
        return view('users')->with('grid', $grid);
    }
    
}