Type a whole stock count into Filament, one column at a time
It is the last day of the month. Someone walks the warehouse with a clipboard and counts every shelf. Back at the desk, the counts have to go into your Filament panel: open a product, click Edit, change the stock, Save, go back to the list, find the next product. For 300 products, that is an afternoon, and one wrong click can save the wrong number on the wrong product.
This article shows the same job with Warp Sheet: the products are listed like a spreadsheet, the counts are typed down one column with the keyboard, and one Save writes them all. Every picture is from the live demo, so you can try it yourself.
The scene: a list of products and one column to fill in
This is the stock count page. SKU, name and category are read-only. Only the "Counted" column can be changed. The demo has 85,045 active products in one sheet, with no pagination.
Step 1: a sheet page for the products
The page is a resource page that extends SheetPage. The sheet gets a query and its columns, and Counted gets the rules it must follow.
use Qalainau\FilamentWarpSheet\Columns;
use Qalainau\FilamentWarpSheet\Pages\SheetPage;
use Qalainau\FilamentWarpSheet\Sheet;
class StockCountSheet extends SheetPage
{
protected static string $resource = StockCountResource::class;
public function sheet(Sheet $sheet): Sheet
{
return $sheet
->query(Product::query()->where('is_active', true))
->columns([
Columns\Text::make('sku')->readOnly()->frozen(),
Columns\Text::make('name')->readOnly(),
Columns\Text::make('category.name'),
Columns\Number::make('stock')
->label('Counted')
->rules(['required', 'integer', 'min:0', 'max:100000'])
->color(fn (?int $value): ?string => match (true) {
$value === 0 => 'danger',
$value < 10 => 'warning',
default => null,
})
->summarize(['sum', 'count']),
])
->searchable(['sku', 'name', 'category.name']);
}
}
In the resource, getPages() returns 'index' => StockCountSheet::route('/'), as for any Filament page. A related column like category.name is shown but never edited.
Step 2: type the counts down the column
Click the first "Counted" cell and type the number. Typing replaces the value, as in a spreadsheet, and Enter moves to the cell below. There is no need to touch the mouse again until the end of the shelf.
While you type, the sheet shows what changed. Changed cells turn orange and get a bar at the left of the row, and the button now reads "Save 7 changes". The colors from color() follow the new values before anything is saved: 3 turns amber (fewer than 10), 0 turns red.
The min:0 and integer rules are checked in the browser the moment a cell changes. A typo like -5 or 12a is marked straight away, with Laravel's message, before anyone presses Save.
Step 3: review, then save everything at once
Before saving, "Review" opens a list of every change, record by record, with the old value crossed out and the new one next to it. A wrong line can be reverted from here.
"Save 7 changes" writes them in one transaction. The save is all or nothing: every record is checked against your policy and the column rules first, and if one fails, its cell is marked and nothing is written.
Keep a record of each count
The demo writes one line per counted product into a stock_counts table, in the same transaction as the save, with afterSave():
->afterSave(function (array $updated): void {
// $updated holds the primary keys that were saved
$countedBy = auth()->user()->name;
foreach (array_chunk($updated, 500) as $keys) {
DB::table('stock_counts')->insert(
Product::query()->whereKey($keys)->pluck('stock', 'id')
->map(fn (int $stock, int $id): array => [
'product_id' => $id,
'counted' => $stock,
'counted_by' => $countedBy,
'created_at' => now(),
'updated_at' => now(),
])->values()->all()
);
}
})
If the stock must not change while someone is counting, beforeSave() can stop the save by throwing SaveAborted with a message for the user.
Show the difference instead of overwriting
In the demo, "Counted" is the product's stock itself, so the count replaces the system quantity. If your count lives in its own column, a computed column shows the difference while people type:
Columns\Number::make('counted_quantity'),
Columns\Computed::make('difference')
->formula('counted_quantity - expected_quantity')
->color(fn (?int $value): ?string => match (true) {
$value > 0 => 'success',
$value < 0 => 'danger',
default => null,
}),
The browser recalculates the formula as soon as a count is typed, before saving.
Other keys that help on count day
- Ctrl/Cmd+D fills the selected range down with the first value (a whole shelf of 0).
- Ctrl/Cmd+V pastes a column copied from a spreadsheet, if the counts were done on a tablet.
- Ctrl/Cmd+Z and Ctrl/Cmd+Y undo and redo, F2 edits a cell without replacing it, Escape cancels.
- The search box and the filters narrow the sheet to one aisle or one category, and the totals follow the filter.
Other scenes for the same sheet
- Goods receipt: type the received quantities next to the ordered ones.
- Price update: search a supplier's products and change one price column.
- Budget: a row per account, a column per month.
- Cleanup: fix categories or names on hundreds of records in one sitting.
Limits worth knowing
- A sheet is a page for a whole resource. For lines inside a form (an order's items), use a repeater.
- There are no formulas typed by users, no multiple sheets and no Excel formatting. Pasting brings values only.
- One save can touch up to 100,000 records by default (
maxChangesPerSave()). - Conflicts use
updated_at. If someone changed the same column after the sheet was loaded, the save stops for that record. A change to another column is merged.
Try it
Open the stock count demo. Click the first "Counted" cell, type a few numbers with Enter after each, press "Review", then save. "Recent counts" shows what you saved. No sign-up, and the data is reset every hour.