Eloquent Collection DataTable

Id Name Email Created At Updated At Action

HTML

<table id="users-table" class="table table-bordered">
    <thead>
    <tr>
        <th>Id</th>
        <th>Name</th>
        <th>Email</th>
        <th>Created At</th>
        <th>Updated At</th>
        <th>Action</th>
    </tr>
    </thead>
</table>

Routes

<?php

Route::get('eloquent/collection', 'Eloquent\CollectionController@index');
Route::get('eloquent/collection-data', 'Eloquent\CollectionController@data');

Controller

<?php

namespace App\Http\Controllers\Eloquent;

use App\Http\Controllers\Controller;
use App\User;
use Yajra\Datatables\Datatables;

class CollectionController extends Controller
{
    /**
     * Display index page.
     *
     * @return \BladeView|bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        return view('eloquent.collection');
    }

    /**
     * Process dataTable ajax response.
     *
     * @param \Yajra\Datatables\Datatables $datatables
     * @return \Illuminate\Http\JsonResponse
     */
    public function data(Datatables $datatables)
    {
        $query = User::all();

        return $datatables->collection($query)
                          ->addColumn('action', 'eloquent.tables.users-action')
                          ->make(true);
    }
}

JS