Проверьте это
// Add this on the top
use Yajra\DataTables\Html\Builder;
use DataTables;
//Controller index method for listing
public function index(Builder $builder, Request $request)
{
$privilege = Privilege::all();
if (request()->ajax()) {
return Datatables::of($privilege)
->addColumn('libelle_privilege',function(User $user){
return $user->privileges()->latest()->first();
})
->make(true);
}
$html = $builder->columns([
['data' => 'name', 'name' => 'name', 'title' => 'Name','width'=>'10%'],
['data' => 'cin', 'name' => 'cin', 'title' => 'Cin','width'=>'10%'],
['data' => 'tel', 'name' => 'tel', 'title' => 'Tel','width'=>'10%'],
['data' => 'adresse', 'name' => 'adresse', 'title' => 'Address','width'=>'40%'],
['data' => 'email', 'name' => 'email', 'title' => 'Email','width'=>'5%'],
['data' => 'nom_utilisateur', 'name' => 'nom_utilisateur', 'title' => 'Nom_Utukusateur','width'=>'5%'],
['data' => 'libelle_privilege', 'name' => 'libelle_privilege', 'title' => 'Libelle Privilege','width'=>'5%'],
])->parameters([
'order' =>'1',
'paging' => true,
'info' => false,
'searchDelay' => 350,
'dom' => 'Bfrtip',
'buttons' => ['print', 'csv', 'excel', 'pdf'],
'searching' => true,
]);
return view('pages.utilisateurs',compact('html'));
}
// In Blade file render tables
<div class="table-responsive">
{!! $html->table(['class' => 'table table-striped'], true) !!}
</div>
JS не требуется для лезвия вообще