Release
tbtop/admin 0.7.1: a resource generator, safer uploads and fixes
A command that writes list, create and edit pages from a model's table, plus stricter uploads, stale sessions signed out, and a long list of fixes across tables, forms and accessibility.
0.7.1 brings one new command: make:tbtop-resource writes the list, create and edit pages for a model from its table. The rest tightens what a form will accept, signs out stale sessions, and fixes a long list of rough spots found in the week since 0.7. Two of them turned up in our new quick-start, where an agent built a blog admin from an empty Laravel app.
Generate a resource
php artisan make:tbtop-resource Post reads the posts table and writes app/Admin/Pages/Posts/: an IndexPage, a CreatePage, an EditPage and a PostFormFields trait the two forms share. It is plain page code you own and edit, not a runtime resource class.
- Each column becomes a field with Laravel rules (
max:N,email,integer,date,nullableonly where the column is). Column defaults prefill the create form. - A unique index becomes a unique rule that ignores the edited record. A foreign key becomes a searchable
relationfield, and a relation column on the table when the model declares it. - BackedEnum casts become a
selectfield and abadgecolumn, Spatie translatable attributes are marked->translatable(), and aslugcolumn fills fromtitleorname. JSON columns get a// TODOinstead of a guess. - The key, timestamps, passwords,
$hiddenattributes and anything mass assignment would drop are left out. - The table gets search, sorting, 25 rows a page, row edit and delete, bulk delete and a record link.
--simplewrites oneIndexPagethat creates and edits in modals.--viewadds a read-onlyViewPage.--policygates the pages and authorizes every record the generated code touches, and runsmake:policywhen there is no policy yet. Without it, the command warns that anyone who can open the panel can write every row.--soft-deletesadds trashed tabs with restore and force delete.--testswrites a stub feature test.- Nothing is overwritten without
--force.
Two smaller additions came with it. Any page can build its own link: EditPage::url(['post' => 5]), see linking to a page. And can() can return ['viewAny', Post::class] to guard a page with a policy; the navigation and MCP use the same check. Every flag and mapping is in the resource generator docs.
Uploads and media
- A form submit only accepts an upload path the record already stores for that field, or one the upload endpoint issued to this session. That holds for single and multiple uploads, repeater rows, translatable fields, action modals and richtext embeds.
- XML-family files (
text/xml,application/xml, XHTML and any+xmltype except SVG) are refused even when a field lists them inaccept. Sanitized SVG and plain text are unaffected. - An image whose header declares more than 40 megapixels is stored as is, with no thumbnails, instead of being decoded.
- A new panel option,
mediaGate('ability'), puts the whole media API behind a gate. It is off by default. - A malformed SVG upload is refused with a validation error again, instead of answering 500.
- A palette PNG uploaded to the media library is stored when webp conversion is on, instead of answering 500 and leaving files behind.
Search and sessions
- Table search, column search, text filters, relation search and media search match
%and_literally. - A column hidden with
visible()can no longer be searched or sorted by through the URL. - Changing a password signs the user's other sessions out on their next request. Pages with their own
middleware()and the MCP route are unchanged. - Array-shaped query parameters (
?search[]=x) are ignored instead of answering 500, on tables, media, selects, relations and uploads.
Fixes you may have hit
- A
datefield filled from$model->toArray()shows its day. It used to stay empty and clear the date on save. admin:install --authwithout a registered panel prints the line to add and a link to the panel docs.- A richtext field whose value is HTML no longer takes focus and scrolls the page when the form loads.
- Clicking Save no longer gets lost when blur validation moves the button.
- Radio, checkbox-list and toggle-button fields show int-backed record values, and an enum case works as an option value.
- A multiple select filter matches every chosen value, and a date range filter keeps its end day on datetime columns.
resetForm()from a form submit handler clears the form.- Bulk restore and force-delete fire model events, like their row versions.
- Ctrl and Cmd shortcuts work on non-Latin keyboard layouts.
Screen readers get named radio, checkbox and toggle groups, helper and error text on more fields, and the current pagination page.
Upgrade
Upgrade tbtop/admin and @tbtop/inertia-admin together to 0.7.1. Two changes can show up in your app. If your code fills an upload field with a path from anywhere but the upload endpoint, the submit is now refused. And a password change ends the user's other sessions, so after a reset they sign in again on their other devices. Every change is in the changelog.
New on the blog: from an empty Laravel app to a blog admin with login, start to finish, with every place it got stuck.