I am using laravel 5 and I want to show field in jenis_surat column in database to my table using datatables. I want to using JSON, do you know how to show the number depends on the entries of the data.
here is my controller (It's just shows data in jenis_surat):
public function jenissurat() {return view('jenissurat');} public function datajenissurat() { $jenissurat = new JenisSurat(); $jenissurats = $jenissurat->select('jenis_surat')->get(); return $jenissurats; } And how to display it on datatables? example:
No. Jenis Surat. .Action
1. . .A . . . . . . . . . Edit | Delete
2. . .B . . . . . . . . . Edit | Delete
3. . .F . . . . . . . . . Edit | Delete
<table id="jenissurat" class="table table-bordered table-striped" cellspacing="0" widht="100%"> <thead> <tr> <th width="4%">No.</th> <th width="80%">Jenis Surat</th> <th width="16%">Action</th> </tr> </thead> </table> <script type="text/javascript"> $(document).ready(function(){ $('#publish').DataTable({ 'columns' : [ {'data' : 'jenis_surat'} ] }); }); </script> Here is my route:
Route::get('/jenissurat', [ 'uses' => 'SuratController@jenissurat', 'as' => 'jenissurat' ]); Route::get('/datajenissurat', [ 'uses' => 'SuratController@datajenissurat', 'as' => 'datajenissurat' ]);here