PHP code example of laralabs / datatablejson

1. Go to this page and download the library: Download laralabs/datatablejson library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laralabs / datatablejson example snippets


'providers' => [
    Laralabs\DataTableJson\DataTableJsonServiceProvider::class
];

use DataTableJsonTrait;

    public $columns = [
        [
            "label" => "ID",
            "field" => "id",
            "searchable" => true,
            "orderable" => true
        ],
        [
            "label" => "First Name",
            "field" => "first_name",
            "searchable" => true,
            "orderable" => true
        ],
        [
            "label" => "Actions",
            "field" => "actions",
            "searchable" => false,
            "orderable" => false,
            "html" => true,
            "content" => '<a class="btn waves-light waves-effect" href="/admin/users/edit/{id}">
                            <i class="fa fa-pencil"></i>
                        </a>'
        ]
    ];

$users = Users::all();
$users->toDataTableJson();

$columns = [
    [
      "....." => "...."
    ]
]
$users = Users::all();
$users->toDataTableJson($columns);

php artisan vendor:publish --tag=config