Table widget
A few records of a resource, e.g. the latest deals.
TableWidget::make('Latest deals') ->resource(DealResource::class) ->columns(['title', 'stage', 'amount']) ->query(static fn (Model $model) => $model->where('stage', 'open')->orderBy('id', 'desc')) ->limit(5) ->span(12);| Method | Default | Description |
|---|---|---|
make(string $label) |
– | heading of the card |
resource(string $class) |
– | resource class; it must be registered in the current panel, otherwise rendering throws a LogicException |
columns(array $names) |
first three columns | names of columns of the resource collection, in this order; unknown names are skipped |
query(Closure $query) |
– | fn (Model $model): restricts or orders the records |
limit(int $limit) |
5 |
number of records, 1–50 |
span(int $span) |
6 |
width on large screens, 3–12 |
key(string $key) |
from the label | stable key of the layout |
- There is no
permission(): the widget is visible when the user may view the list of the resource (canViewAny()). - The query runs through
$resource->query(): tenant andscopeQuery()apply. - The columns render exactly as in the list (badges, money, links, related counts). The first column links to the detail page of the record when the user may view that record.
- Show all in the header opens the list of the resource.