@extends('layouts.app')

@section('content')
         <div class="container">
               <h2>Usuários</h2>
            <table class="table table-bordered" id="laravel_datatable">
               <thead>
                  <tr>
                     <th>Id</th>
                     <th>Name</th>
                     <th>Email</th>
                     <th>Created at</th>
                     <th>Editar</th>
                  </tr>
               </thead>
            </table>
         </div>
   <script>
   $(document).ready( function () {
    $('#laravel_datatable').DataTable({
           processing: true,
           serverSide: true,
           ajax: "{{ url('users-list') }}",
           columns: [
                    { data: 'id', name: 'id' },
                    { data: 'name', name: 'name' },
                    { data: 'email', name: 'email' },
                    { data: 'created_at', name: 'created_at' },
                    { data: 'id', name: 'id', render:function(data, type, row){
                        return "<a class='btn btn-outline-info' href='users/"+ row.id +"/edit'><i class='far fa-eye' aria-hidden='true'></i></a>"
                        }}
                     ,
                 ]
        });
     });
  </script>
@endsection
