Skip to content

Admin screens

Alexey Averikhin edited this page Dec 4, 2026 · 1 revision

One command generates a complete admin screen: model, migration, list, form, permission, menu entry, texts and tests.

Generate one

make shell
php artisan app:make-feature Product
php artisan migrate

Open http://localhost/admin/products as the administrator. Products is in the sidebar, with a searchable list, CSV export and forms to add, change and delete.

What it writes

Model, migration, factory app/Models/Product.php, database/migrations/…_create_products_table.php, database/factories/ProductFactory.php
The screen app/Http/Controllers/Admin/ProductController.php, its route in routes/web.php, breadcrumbs in routes/breadcrumbs.php
Who may open it the products.manage permission in config/permissions.php, the menu entry in config/menu.php
Texts lang/en.json
Tests tests/Feature/ProductScreenTest.php: permissions, listing, search, create, change, delete, validation

Make it yours

  1. Add your columns to the migration, $fillable in the model, the factory, and columns() and fields() in the controller. The Gentelella for Laravel docs list every column and field type. AnnouncementController is a complete example: an excerpt column, field hints, a CSV export.
  2. Let other roles in. Administrators see the screen at once. For another role, tick products.manage on the role's page under Roles.
  3. Check it with make check: code style, static analysis and all tests, yours included.

Rules the screens keep

  • Every admin route is in the admin middleware group and asks for its permission with can:. Tests fail when one doesn't.
  • Data changes use POST, PUT, PATCH or DELETE with CSRF protection; destructive actions ask for confirmation.
  • Writable attributes are listed in $fillable.

Known limit

CSV exports don't neutralize spreadsheet formulas. Take care opening exports of text that users typed.

Clone this wiki locally