sevak88 / admin
A scalable CRUD admin for Laravel models.
Requires
- php: ^8.4
- bacon/bacon-qr-code: ^3.0
- illuminate/contracts: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- symfony/html-sanitizer: ^7.4|^8.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pint: ^1.27
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0|^5.3
- pestphp/pest-plugin-laravel: ^4.0|^5.0
- spatie/laravel-medialibrary: ^11.0
Suggests
- ext-intl: Names countries and languages in the admin's language.
- ext-xmlwriter: Needed for Excel (XLSX) list exports.
- ext-zip: Needed for Excel (XLSX) list exports.
- spatie/laravel-medialibrary: Needed for the Media field (^11.0).
Provides
None
Conflicts
None
Replaces
None
README
sevak88/admin
A CRUD admin for Laravel models. Point it at a model and get a searchable list, forms and a detail page, with its own login that stays separate from your application's users.
It needs PHP 8.4 or later and Laravel 12 or 13. Hosts do not need Node.
Documentation, with screenshots of every screen: admin.webtop.us
Lists with search, sorting and inline editing |
Forms with sections and validation |
Filters |
Bulk actions |
Installation
composer require sevak88/admin php artisan admin:install
The install command publishes the package's files, runs the migrations and helps you create the first admin. Open /admin-app and log in.
Adding a model
php artisan admin:resource Post
This reads the model's table and creates app/Admin/PostResource.php and a policy. Resources in app/Admin are found automatically.
class PostResource extends Resource { public static function model(): string { return Post::class; } public function fields(): array { return [ Text::make('Title')->rules(['required', 'max:255'])->sortable()->searchable(), Textarea::make('Body'), BelongsTo::make('Category')->resource(CategoryResource::class), ]; } }
To give the list its own columns and order, add a columns() method that returns fields. Columns are display only.
To switch an action off for everyone, return it from deniedActions(), such as RecordAction::Delete. It is refused on the server as well as hidden.
The generated policy allows every admin user, so tighten it if admins need different access. A model with no policy is denied.
Fields
| Kind | Fields |
|---|---|
| Text | Text, Textarea, RichText, Email, Url, Slug, Password |
| Numbers and choices | Number, Price, Boolean, Select, Color |
| Dates and times | Date, DateTime, Time |
| Files | File, Image, Gallery, FileManager |
| Relationships | BelongsTo, BelongsToMany, HasMany |
| Groups | Repeater, and Tab to split a form into sections |
The fields guide explains when to use each one, with screenshots.
Each field type validates its own values, and only declared fields are ever read or written.
A field can show only while another field has a certain value. The form shows and hides it as people type, and the server checks the same condition when saving, so a hidden field is never validated or written:
Number::make('Discount')->showWhen('on_sale', true)->rules(['required']),
A field's choices can also follow another field, such as cities by country. The server narrows them and validates against the same list:
BelongsTo::make('City')->resource(CityResource::class) ->dependsOn('country', fn (BelongsTo $field, array $values) => $field ->scopeOptions(fn (Builder $query) => $query->where('country_id', $values['country']))),
Text fields can hold one value per language. Store them in a JSON column with an array cast, or use spatie/laravel-translatable, and list the languages in content_locales:
Text::make('Title')->translatable()->rules(['required', 'max:255']),
The form gets a language switcher, and the first language is the main one: it is required when the field is, and shown wherever a translation is missing. admin:resource makes JSON columns translatable for you.
Dashboard
Admins land on a dashboard after logging in. List widgets in app/Admin/Dashboard.php to show your own numbers on it:
class Dashboard extends \Sevak88\Admin\Dashboard { public function widgets(): array { return [ Metric::make('New orders')->count(OrderResource::class)->ranges(DateRange::Last30Days, DateRange::Last7Days), Trend::make('Orders per day')->count(OrderResource::class)->ranges(DateRange::Last30Days)->area(), Breakdown::make('Orders by status')->count(OrderResource::class)->groupBy('status'), RecordList::make('Latest orders')->resource(OrderResource::class), ]; } }
Widgets are metric cards, trend and breakdown charts, record lists, progress bars, tables, notes and quick actions. Widgets over a resource read only the records it shows, and only appear for admins who can list it. Each widget loads its own data, and charts load their drawing code only when the dashboard has one. See the dashboard guide.
Users and access
The admin has its own guard, admin_users table and login page, so your application's users cannot log in to it.
php artisan admin:make-user
Registration with email verification is available, and off by default. New accounts can open the admin, so restrict access with the viewAdmin gate and your policies before you enable it:
ADMIN_REGISTRATION=true ADMIN_EMAIL_VERIFICATION=true
An Admin users screen manages admins from the admin itself, and roles limit each admin to chosen resources and abilities, with super admin roles that allow everything. Both are off by default. Before turning roles on in a project that already has admins, run admin:roles, which makes every current admin a super admin, so nobody is locked out:
php artisan admin:roles
ADMIN_USERS=true ADMIN_ROLES=true
Roles turn the Admin users screen on too. Model policies still apply on top of roles.
With roles on, super admins can also log in as any other admin from the Admin users screen, and return to their own account from a bar at the top. It is off by default:
ADMIN_IMPERSONATION=true
Customising
Change the URL, middleware and other settings in config/admin.php. The prefix can also be set with ADMIN_PATH.
Publish only the part you want to change:
php artisan admin:publish # search and pick php artisan admin:publish --list # list everything, with what you published php artisan admin:publish views/login php artisan admin:publish views/partials/guest/brand php artisan admin:publish lang/ui php artisan admin:publish fields/text php artisan admin:publish parts/sidebar php artisan admin:publish parts/dashboard php artisan admin:publish widgets/metric
Views, language files and config work as soon as you edit them. A published field, screen part or widget needs Node, because it has to be compiled. The command shows you how.
To add a new field or widget type, write a plugin. examples/color-picker in the repository is a complete one.
To see the admin with realistic data, copy examples/ember-roasters, a small coffee shop with products, customers, orders and a dashboard, into a fresh Laravel app. Its README has the three commands.
Icons and themes
Set a resource's sidebar icon with icon(), using any Lucide icon name, such as file-text or users.
The admin has light and dark themes. It follows the system setting until someone chooses, and the choice is remembered in that browser. Give it your logo and accent colour in .env:
ADMIN_LOGO=images/logo.svg ADMIN_BRAND_COLOR=#c2410c
For anything more, override the --admin-* CSS variables.
Languages
All text is in language files. To add a language, create lang/vendor/admin/{locale}/ with translated copies of ui.php, auth.php and mail.php, then list it in config/admin.php:
'locales' => [ 'en' => 'English', 'de' => 'Deutsch', ],
A language selector appears when more than one locale is listed. It only changes the admin, not your application. Anything you leave untranslated falls back to English.
These are the admin's interface languages. The languages your records are written in are a separate setting, content_locales. See Fields above.
Updating
composer update sevak88/admin php artisan admin:install
The install command is safe to run again. It refreshes the compiled assets, adds new migrations and keeps your edited files.
Documentation
The documentation has a guide for everything in this README and more: installation, a first CRUD, every field, filters, actions, exports, the history, the dashboard, roles, two-factor login, languages, branding, extending the admin and a configuration reference, with screenshots of each screen.
License
MIT. See LICENSE.