Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel datatables

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>
Comment

PREVIOUS NEXT
Code Example
Php :: php creating a subdomain automatically in cpanel 
Php :: check if column has value in laravel eloquent 
Php :: wp_schedule_event 
Php :: auto reload for laravel 
Php :: laravel download file change name 
Php :: get romawi number php 
Php :: Clear any previous error php 
Php :: phpmyadmin export database 
Php :: namespace in php 
Php :: namecheap shared cpanel change php version for subdomain 
Php :: how to login first before see index php 
Php :: to enable php in apache 
Php :: php huruf besar di awal 
Php :: check if any values are the same in an array php 
Php :: create resource controller in admin folder laravel 
Php :: laravel email validation 
Php :: public variable in php 
Php :: laravel change db connection on the fly 
Php :: You are *required* to use the date.timezone setting or t 
Php :: how to back the page laravel where the scorll is 
Php :: check if config exist laravel 
Php :: wordpress raw query 
Php :: Get the current script file name 
Php :: blade directive 
Php :: php fpdf in phpmailer 
Php :: 0 
Php :: add a snippet in twig shopware 6 
Php :: does xampp install php 
Php :: php multi string to single string 
Php :: $wpdb foreach 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =