nicelizhi/laravel-admin
A Laravel admin panel package for quickly building CRUD backends and administrative interfaces in PHP applications. It offers common scaffolding for models, forms, and data grids, helping streamline backend development and management.
Install the package into an existing Laravel application and run the installer:
composer require nicelizhi/laravel-admin
php artisan admin:install
admin:install publishes config/admin.php, runs the package migrations (admin_users, admin_roles, admin_permissions, admin_menu, pivot tables), seeds a default administrator, and publishes assets. Log in at /admin with admin / admin and change that password before doing anything else.
Where to look first:
config/admin.php — route prefix, auth guard, database connection, upload disk/directory, layout and title.app/Admin/routes.php — every generated controller must be registered here.app/Admin/Controllers/ — generated CRUD controllers live here.app/Admin/bootstrap.php — global grid/form extensions and macros.vendor/nicelizhi/laravel-admin/ — this is a fork of encore/laravel-admin; when the upstream docs disagree with behavior, the vendor source is authoritative.First use case: scaffold a back-office screen for an existing model.
php artisan admin:make PostController --model=App\\Models\\Post
Then register it:
// app/Admin/routes.php
$router->resource('posts', PostController::class);
Visit /admin/posts. The generated controller gives you a grid (list), a form (create/edit), and a detail view. That generate-register-tune loop is the core of day-to-day work with this package.
Release 1.0.7 adds “apps modules pages.” After upgrading, check whether the new pages need published views/assets or menu entries:
php artisan vendor:publish --provider="Encore\\Admin\\AdminServiceProvider" --force
php artisan admin:import # if your version ships a menu import command
Confirm the provider FQCN in vendor/nicelizhi/laravel-admin/composer.json before running the publish command.
CRUD generation loop. Use admin:make for each resource, then edit only the grid() and form() methods. Keep generated controllers thin and push reusable behavior into base controllers or traits under app/Admin/Controllers.
Grid configuration. The grid is where most time is spent:
protected function grid()
{
$grid = new Grid(new Post());
$grid->model()->with(['author', 'category']); // eager-load to avoid N+1
$grid->column('id')->sortable();
$grid->column('title')->filter('like');
$grid->column('author.name', 'Author');
$grid->column('status')->using([0 => 'Draft', 1 => 'Published'])->label();
$grid->column('created_at')->sortable();
$grid->filter(function ($filter) {
$filter->like('title');
$filter->equal('status')->select([0 => 'Draft', 1 => 'Published']);
});
return $grid;
}
Form configuration. Prefer $form->rules() for validation and model relationship methods (belongsTo, hasMany) over manual select option arrays:
$form->text('title')->rules('required|max:255');
$form->select('status')->options([0 => 'Draft', 1 => 'Published']);
$form->belongsTo('author_id', Author::class);
$form->image('cover')->uniqueName()->move('posts');
$form->rules(['title' => 'required|max:255']);
For unique rules on update, ignore the current record: Rule::unique('posts')->ignore($form->model()->id).
Detail view. Use $show->field('title') and $show->field('body')->unescape(); keep the show page read-only unless there is a real need to edit inline.
Menus and permissions. Menu entries are database-driven. Manage them through /admin/auth/menu or by inserting into admin_menu; avoid hardcoding menu HTML. Roles and permissions are also DB-driven — bind generated controllers to permissions so non-super-admins see only what they should. New controllers are visible to the super-admin role immediately, so audit access before handing accounts out.
Custom pages and widgets. Use the package’s page/controller generators (php artisan list admin shows what your version provides) for dashboards and report screens. Register reusable grid/form macros in app/Admin/bootstrap.php so they are available across controllers.
Integration tips.
auth.guard in config/admin.php and the guard definition in config/auth.php.php artisan storage:link.auth:web on admin routes.encore/laravel-admin, but version numbers and command names can diverge. When a documented method is missing, grep vendor/nicelizhi/laravel-admin/src for the actual method name before assuming a bug.php artisan migrate after upgrading, and compare vendor/nicelizhi/laravel-admin/database/migrations/ against any migrations you previously published into database/migrations/. If you published them earlier, the package’s corrected migration will not be applied — published files shadow package files. Diff and patch manually, and back up the affected table first.config/admin.php run php artisan config:clear; after registering a new controller run php artisan route:clear. Stale caches produce 404s that look like routing bugs.$grid->model()->with([...]). Avoid display() closures that query per row; they silently turn a 20-row page into dozens of queries.$grid->column('name') conflicts with model methods or appended attributes. Use ->pluck('name') or rename the column when output looks wrong.upload.disk, upload.directory, the storage symlink, and file permissions. A silent upload failure usually means the disk is misconfigured, not that the form field is broken./admin/auth/permissions and role bindings after adding resources.APP_DEBUG=true locally, watch storage/logs/laravel.log, and use the package’s exception handler before adding custom error pages. For form/grid issues, dump the generated SQL with DB::listen rather than guessing.app/Admin/bootstrap.php is the right place for macros and global behavior; avoid editing vendor files, since the next composer update will overwrite them.How can I help you explore Laravel packages today?