Skip to content

Create a Controller

Patrick Samson edited this page Feb 19, 2016 · 4 revisions

Add a Route

Add this in your routes.php file

Route::controller('/datagrid', 'DatagridController');

Create a Controller

<?php
namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Lykegenes\DatagridBuilder\DatagridBuilder;

class DatagridController extends Controller
{

    public function getIndex(DatagridBuilder $builder)
    {
        $datagrid = $builder->create('App\Datagrids\UsersDatagrid')
            ->setUrl('/datagrid/api-response');

        return view('demo-datagrid', compact('datagrid'));
    }

    public function getApiResponse()
    {
        // Return some JSON here.
        // We will add it later in this tutorial.
    }

}
Clone this wiki locally