PHP code example of team-nifty-gmbh / tall-datatables

1. Go to this page and download the library: Download team-nifty-gmbh/tall-datatables 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/ */

    

team-nifty-gmbh / tall-datatables example snippets


class UserDataTable extends DataTable
{
    protected string $model = User::class;

    public array $enabledCols = ['name', 'email', 'created_at'];
}

protected function availableLayouts(): array
{
    return ['table', 'grid', 'kanban'];
}

protected function availableLayouts(): array
{
    return ['table', 'grid'];
}

protected function availableLayouts(): array
{
    return ['table', 'kanban'];
}

// Which column determines the lanes
protected function kanbanColumn(): string
{
    return 'state';
}

// Optional: explicit lane config (order, labels, colors)
protected function kanbanLanes(): ?array
{
    return [
        'open' => ['label' => 'Open', 'color' => 'emerald'],
        'in_progress' => ['label' => 'In Progress', 'color' => 'amber'],
        'done' => ['label' => 'Done', 'color' => 'indigo'],
    ];
}

// Handle drag & drop
public function kanbanMoveItem(int|string $id, string $targetLane): void
{
    MyModel::findOrFail($id)->update(['state' => $targetLane]);
}

// Optional: custom card blade view
protected function kanbanCardView(): ?string
{
    return 'components.my-kanban-card';
}

public bool $isFilterable = true;

protected function canShareFilters(): bool
{
    return true;
}

// Restrict sortable columns (default: all)
public array $sortable = ['name', 'created_at'];

public bool $isSelectable = true;

public array $enabledCols = [
    'name',
    'email',
    'department.name',
    'department.manager.email',
];

public array $enabledCols = ['name', 'orders_count', 'comments_count'];

// Disable export (enabled by default)
public bool $isExportable = false;

protected function getRowActions(): array
{
    return [
        DataTableButton::make('edit')
            ->label(__('Edit'))
            ->icon('pencil')
            ->wireClick('edit(record.id)'),
    ];
}

protected function getRowDragDropConfig(): ?array
{
    return [
        'column' => 'sort_order',
    ];
}

use TeamNiftyGmbH\DataTable\Formatters\FormatterRegistry;

app(FormatterRegistry::class)->register(MyCast::class, new MyFormatter());

protected function augmentItemArray(array &$itemArray, Model $item): void
{
    $itemArray['full_name'] = $item->first_name . ' ' . $item->last_name;
}

public function getSidebarTabs(): array
{
    $tabs = parent::getSidebarTabs();

    $tabs[] = [
        'id' => 'my-tab',
        'label' => __('My Tab'),
        'view' => 'components.my-custom-tab',
    ];

    return $tabs;
}

public bool $positiveEmptyState = true;

protected function canSaveDefaultColumns(): bool
{
    return true;
}
bash
php artisan vendor:publish --tag="tall-datatables-migrations"
php artisan migrate