PHP code example of givanov95 / laravel-data-table
1. Go to this page and download the library: Download givanov95/laravel-data-table 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/ */
use Givanov95\DataTable\Columns\RelationColumn;
$table->setRelationColumn(
new RelationColumn('user.name', __('User'), searchable: true, orderable: true)
);
use Givanov95\DataTable\Columns\TranslatableColumn;
$table->setTranslatableColumn(
new TranslatableColumn(
locale: app()->getLocale(),
translationKey: 'title',
label: __('Title'),
searchable: true,
orderable: true,
)
);
// Enum filtering by case name
$table->setEnumColumn('status', App\Enums\OrderStatus::class);
// Numeric-only filtering (currency / numeric input)
$table->setPriceColumn('price');
// Date filtering with timezone-aware parsing
$table->setDateColumn('created_at', 'd.m.Y H:i:s');