I need ID attribute in HTML table of Laravel Datatable (https://github.com/yajra/laravel-datatables) like below.
I am using Laravel 5.4 and Datatable 7.x. I am using AdminLTE also. My controller is like below. I need the ID attribute.
UsersController.php
<?php
namespace App\Http\Controllers;
use DB;
use Validator;
use Datatables;
use App\Http\Requests;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use App\Users;
class UsersController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
return view('adminlte::users');
}
/**
* return data for dashboard.
*
* @return Response
*/
public function get_users()
{
$users = Users::select(['id','name', 'user_name', 'email',]);
return Datatables::of($users)
->addColumn('action', function ($users) {
return '<button class="edit-modal btn btn-xs btn-primary">
<span class="glyphicon glyphicon-edit"></span> Edit
</button>';
})
->make(true);
}
}
My JavaScript code is like below.
<script type="text/javascript">
//Display datatable
$(function() {
$('#users').DataTable({
processing: true,
serverSide: true,
ajax: "{{ route('get_users') }}",
columns: [
{data: 'id', name: 'id'},
{data: 'name', name: 'name'},
{data: 'email', name: 'email'},
{data: 'action', name: 'action', orderable: false, searchable: false}
]
});
});
</script>
How can I get the output ?

->setRowId('id'). Thanks