Warp Matrix demo — a row × column input field for Filament: stock by size and color, prices, permissions. Change anything; the data is reset every hour. warpui.com About Warp Matrix Docs Ask a question Support
Skip to content

Roles and permissions

Who may do what at Maple Thread: a role in each row, a permission in each column. This is a settings page with no record. The last example is the real setting: it is saved in the role_permissions table.

A checkbox in each cell

->checkbox() puts a checkbox in each cell. A checked cell is saved as true; an unchecked one is left out.

Note: Try it

Click anywhere in the Sales associate × Refunds cell: it is checked. Click “Show what would be saved”: "orders.refund": true is now under associate.

What each role may do
Role
View
Edit
Stock
Refunds
Reports
Owner
Store manager
Sales associate
Accountant
Seasonal helper

Check a whole row or column at once

->bulkToggleable() adds a small round button next to each role and each permission. It is shown faintly at all times and gets darker when you point at the name. It checks every cell of its row or column, or unchecks them all if they are all checked already. The button next to “Role” in the corner does the whole table.

Note: Try it

Click the round button next to “Seasonal helper” on the left: the whole row is checked. Click it again: the whole row is unchecked. Do the same with “Reports” at the top for a column.

What each role may do
Role
View
Edit
Stock
Refunds
Reports
Owner
Store manager
Sales associate
Accountant
Seasonal helper

Roles in groups

Give ->rows() an array of arrays: the outer keys (In the store, Outside the store) are written as a line above their roles.

Note: Try it

Look at the left of the table: Owner, Store manager and Sales associate are under “In the store”, Accountant and Seasonal helper under “Outside the store”.

What each role may do
Role
View
Edit
Stock
Refunds
Reports
In the store
Owner
Store manager
Sales associate
Outside the store
Accountant
Seasonal helper

Saved in a table, with the Owner row locked

A page with no record reads and saves with ->store(MatrixStore::make(RolePermission::class, row: 'role', column: 'permission')): a row in role_permissions means the cell is checked. The Save button calls saveToStore(), which writes only the cells you changed. ->disabledCells() locks the Owner row: it is shown but cannot be changed, and the server keeps it as saved.

Note: Try it

Check Accountant × View and click Save permissions: the message says 1 added. Reload the page: it is still checked. Uncheck it, save again: the message says 1 removed, and it stays unchecked after a reload. Try to click a cell in the Owner row: nothing changes.

Permissions at Maple Thread
Role
View
Edit
Stock
Refunds
Reports
In the store
Owner
Store manager
Sales associate
Outside the store
Accountant
Seasonal helper