Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Admin Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

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.

  • Keep the admin guard separate from the application guard; verify auth.guard in config/admin.php and the guard definition in config/auth.php.
  • If the admin panel shares a database with the main app, set the package connection explicitly rather than relying on the default.
  • Put upload paths on a dedicated disk and run php artisan storage:link.
  • Use the package’s auth middleware rather than auth:web on admin routes.

Gotchas and Tips

  • Fork drift. This package tracks 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.
  • 1.0.7 database fix. The release notes say “fix database bug.” Run 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 and route caches. After editing 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.
  • Stale assets. After every upgrade, republish assets and hard-refresh the browser. Mismatched CSS/JS between the published assets and the new package version causes broken grids and forms that are easy to misdiagnose.
  • Missing new module pages. The 1.0.7 “apps modules pages” may require a publish step, a menu entry, or a migration. If the pages do not appear, check the package’s view directory and menu seed before writing your own.
  • N+1 queries in grids. Use $grid->model()->with([...]). Avoid display() closures that query per row; they silently turn a 20-row page into dozens of queries.
  • Column name collisions. $grid->column('name') conflicts with model methods or appended attributes. Use ->pluck('name') or rename the column when output looks wrong.
  • Upload failures. Check 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.
  • Permission surprises. A new controller may be reachable by roles you did not intend. Review /admin/auth/permissions and role bindings after adding resources.
  • Debugging. Keep 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.
  • Extension points. 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.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route