Skip to main content
You are currently viewing the documentation for Filament 2.x, which is a previous version of Filament.Looking for the current stable version? Visit the 5.x documentation.
Filament comes with a “table” widget template, which you can use to display a table of data without needing to write a custom view. Start by creating a widget with the command:
php artisan make:filament-widget LatestOrders --table
Then update the getTableQuery() and getTableColumns() methods to return the data query and columns you want to display:
<?php

namespace App\Filament\Widgets;

use App\Models\Order;
use Closure;
use Filament\Tables;
use Filament\Widgets\TableWidget as BaseWidget;
use Illuminate\Database\Eloquent\Builder;

class LatestOrders extends BaseWidget
{
    protected function getTableQuery(): Builder
    {
        return Order::query()->latest();
    }

    protected function getTableColumns(): array
    {
        return [
            Tables\Columns\TextColumn::make('id'),
            Tables\Columns\TextColumn::make('customer.name')
                ->label('Customer'),
        ];
    }
}
Now, check out your widget in the dashboard. Table widgets support all features of the Table Builder, including filters and actions.

Sponsored by