rynbd / lyrapanel
A powerful admin & user dashboard with RBAC and dynamic CRUD for Laravel 12
Requires
- php: ^8.2
- laravel/framework: ^12.0
- laravel/sanctum: ^4.0
Requires (Dev)
- orchestra/testbench: ^10.0
- pestphp/pest: ^3.0
This package is not auto-updated.
Last update: 2026-03-11 14:56:54 UTC
README
A comprehensive, production-ready Laravel 12 admin panel package with RBAC, dynamic CRUD, user management, audit trails, and more.
Features
- Role-Based Access Control (RBAC) — Roles and fine-grained privileges with middleware
- User Management — Full CRUD, suspension, impersonation, role assignment
- Dynamic Resource CRUD — Register any Eloquent model for automatic CRUD via
HasDynamicCrudtrait - Admin & User Dashboards — Separate dashboards with stats and quick actions
- Audit Trail — Comprehensive logging of all admin actions with old/new value diff
- User Impersonation — Login as any user with one click (admin-only)
- Invitation System — Invite users via email with role pre-assignment
- Settings Management — UI-based configuration for branding, features, and themes
- Admin Bar — Global notice bar for system-wide announcements
- Dark/Light Theme — Toggle between themes with
localStoragepersistence, shadcn/ui-inspired CSS variables - Artisan Install Command — Interactive installer for quick setup
Requirements
- PHP 8.2+
- Laravel 12.x
- Laravel Sanctum 4.x (included)
Installation
1. Require the package
composer require rynbd/lyrapanel
2. Run the install command
php artisan lyra:install
This interactive command will:
- Publish configuration and migration files
- Run migrations to create required tables
- Add required traits to your
Usermodel - Seed default roles and privileges
- Create an admin user
Manual Installation
If you prefer manual setup:
# Publish config php artisan vendor:publish --tag=lyrapanel-config # Publish migrations php artisan vendor:publish --tag=lyrapanel-migrations # Run migrations php artisan migrate
Then add the following traits to your User model:
use Rynbd\LyraPanel\Traits\HasRoles; use Rynbd\LyraPanel\Traits\HasPrivileges; use Rynbd\LyraPanel\Traits\HasSuspension; class User extends Authenticatable { use HasRoles, HasPrivileges, HasSuspension; }
Configuration
Publish and edit the config file at config/lyrapanel.php:
return [ 'routes' => [ 'prefix' => 'panel', // URL prefix 'middleware' => ['web', 'auth'], // Applied middleware 'admin_middleware' => ['role:admin'], // Admin-only middleware ], 'pagination' => ['per_page' => 15], 'audit' => ['enabled' => true], 'impersonation' => ['enabled' => true], 'invitations' => ['enabled' => true], 'branding' => [ 'name' => 'LyraPanel', 'logo' => null, ], // ...more options ];
Usage
Roles & Privileges
// Assign roles $user->assignRole('admin'); $user->assignRole('editor'); // Check roles $user->hasRole('admin'); // true $user->hasAnyRole(['admin', 'editor']); // true // Check privileges (through roles) $user->hasPrivilege('users.create'); $user->can('posts.edit'); // alias for hasPrivilege
Middleware
// In routes Route::middleware('role:admin')->group(function () { // Admin-only routes }); Route::middleware('privilege:posts.create')->group(function () { // Routes requiring specific privilege }); Route::middleware('not-suspended')->group(function () { // Block suspended users });
Dynamic CRUD Resources
Add the HasDynamicCrud trait to any model:
use Rynbd\LyraPanel\Traits\HasDynamicCrud; class Post extends Model { use HasDynamicCrud; public static function crudFields(): array { return [ 'title' => [ 'type' => 'text', 'label' => 'Title', 'rules' => 'required|max:255', 'list' => true, // Show in list view 'form' => true, // Show in create/edit form ], 'body' => [ 'type' => 'textarea', 'label' => 'Content', 'rules' => 'required', 'list' => false, 'form' => true, ], 'status' => [ 'type' => 'select', 'label' => 'Status', 'options' => ['draft' => 'Draft', 'published' => 'Published'], 'rules' => 'required|in:draft,published', 'list' => true, 'form' => true, ], 'featured_image' => [ 'type' => 'image', 'label' => 'Featured Image', 'rules' => 'nullable|image|max:2048', 'list' => true, 'form' => true, ], ]; } }
Register the resource in config/lyrapanel.php:
'resources' => [ 'posts' => [ 'model' => \App\Models\Post::class, 'label' => 'Posts', 'icon' => 'document', ], ],
Supported field types: text, textarea, number, email, select, boolean, date, datetime, image, file.
User Suspension
// Suspend a user $user->suspend('Violation of terms', now()->addDays(7)); // Unsuspend $user->unsuspend(); // Check status $user->isSuspended(); // bool
Audit Logging
use Rynbd\LyraPanel\Support\AuditLogger; // Manual logging AuditLogger::log('custom_action', $model, 'Description of what happened'); // With old/new values AuditLogger::logUpdate($model, $oldValues, $newValues);
Impersonation
Admins can impersonate users from the Users management page. A yellow banner shows when impersonating, with a "Return to Admin" button.
Route Structure
| Route | Description |
|---|---|
/panel/admin |
Admin Dashboard |
/panel/admin/users |
User Management |
/panel/admin/roles |
Role Management |
/panel/admin/privileges |
Privilege Management |
/panel/admin/resources/{resource} |
Dynamic CRUD |
/panel/admin/audit |
Audit Logs |
/panel/admin/settings |
Settings |
/panel/admin/invitations |
Invitations |
/panel/user |
User Dashboard |
/panel/user/profile |
User Profile |
Customization
Views
Publish views for customization:
php artisan vendor:publish --tag=lyrapanel-views
Theme
The package uses shadcn/ui-inspired CSS variables. Customize in the published layout files or override in your CSS:
:root { --primary: #3b82f6; --background: #ffffff; --foreground: #0f172a; } .dark { --primary: #3b82f6; --background: #0f172a; --foreground: #f8fafc; }
License
MIT License. See LICENSE for details.# lyra-panel