Star

Object data source

Use named properties instead of arrays

You may want to convey more information in the data source than is necessary to show in the table (row IDs from the database for example).
For these situations DataTables supports reading data as objects. Use columns.data to map each property.
Id Name Unit Price
Loading…
<?php
use Ozdemir\Datatables\Datatables;
use Ozdemir\Datatables\DB\SQLite;

Route::get('/ajax/object-data-source', function () {
    $path = dirname(__DIR__).'/database/Chinook_Sqlite_AutoIncrementPKs.sqlite';

    $dt = new Datatables(new SQLite($path));
    $dt->query('Select TrackId, Name, UnitPrice from Track');

    return $dt->generate();
});