I read a lot on this issue from datatable.net but couldn't figure out what the problem is. I also read from threads on this platform but couldn't find the solution to my specific problem. I am building an app with acl in laravel 5.6 and using datatable v 1.10.19 and jquery 3.2 Anytime I request data to be displayed by datatable, I get this alert(DataTables warning: table id=users - Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4)
This is my view
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<table id="users" class="table table-strped table-dark">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Email</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div><!-- /.container-fluid -->
</div>
And this is my controller
public function AllUser() {
$user = User::all();
return Datatables::of($user)
->addColumn('action', function($user) {
'<a onclick="showData('.$user->id.')" class="btn btn-sm btn-success">Show</a>'.' '.
'<a onclick="showData('.$user->id.')" class="btn btn-sm btn-info">Edit</a>'.' '.
'<a onclick="showData('.$user->id.')" class="btn btn-sm btn-danger">Delete</a>';
})->make(true);
}
My model is the normal user model that comes with laravel integrated with spartie
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
And this is my web route
Route::get('/all/user', 'UserController@AllUser')->name('allusers');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire