home.blade.php
@extends('layouts.app')
@section('content')
...
<table id="users-data-table" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th>ID</th>
<th>Nome</th>
<th>Email</th>
<th>Regra</th>
<th>Verificado</th>
<th>Data de criação</th>
{{--<th>Ações</th>--}}
</tr>
</thead>
<tbody>
@foreach($users as $user)
<tr>
<td>{{ $user->id }}</td>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->role }}</td>
<td>{{ $user->email_verified_at }} </td>
<td>{{ $user->created_at }}</td>
{{--<td>
<a href="{{ route('users.edit', $user->id) }}" class="btn btn-primary">Editar</a>
<form action="{{ route('users.destroy', $user->id) }}" method="POST">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">Remover</button>
</form>
</td>--}}
</tr>
@endforeach
</tbody>
</table>
app.blade.php
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
...
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css">
</head>
<body>
...
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
$('#users-data-table').DataTable({
"language": {
"url": "https://cdn.datatables.net/plug-ins/1.11.5/i18n/pt-BR.json"
},
"columnDefs": [
{ "targets": [5], "searchable": false },
{ "bSortable": false, "aTargets": [ 0,5 ] }
],
/* active column position */
"order": [[3, "asc" ]]
});
} );
</script>
</body>