If you are using yajra laravel datatables
Just add ->addIndexColumn()
return DataTables::of($data) ->addIndexColumn() ->make(true);
In your javascript, you can set the first row as a serial number like this
columns: [ { data: 'DT_RowIndex', name: 'DT_RowIndex', orderable: false, searchable: false }, { data: 'name', name: 'name' }, { data: 'action', name: 'action' } ]
use DT_Row_Index instead of DT_RowIndex for older yajra datatable version