⚠️ EXPERIMENTAL BETA VERSIONThis package is under active development. API may change in future versions.
Package for creating multiple admin panels in one MoonShine application with independent settings, routes and interfaces.
- MoonShine 4.4+
- Laravel 10+
- PHP 8.2+
composer require moonshine/multi-panelsOpen config/moonshine.php and set:
'use_routes' => false,IMPORTANT: Add MultiPanelMiddleware to the middleware configuration. You can add it at the top-level (for all panels) or to specific panels.
// config/moonshine.php
'middleware' => [
// ... other middleware
\MoonShine\MultiPanels\Http\Middleware\MultiPanelMiddleware::class,
],// config/moonshine.php
'panels' => [
'admin' => [
'prefix' => 'admin',
'middleware' => [
'moonshine',
\MoonShine\MultiPanels\Http\Middleware\MultiPanelMiddleware::class,
],
],
'test' => [
'prefix' => 'test',
'middleware' => [
'moonshine',
\MoonShine\MultiPanels\Http\Middleware\MultiPanelMiddleware::class,
],
],
],In the same config/moonshine.php file add panels section:
'panels' => [
'admin' => [
'prefix' => '',
'title' => 'Admin panel',
],
'test' => [
'prefix' => 'test',
'title' => 'Test panel',
'palette' => SkyPalette::class,
// 'layout' => AppLayout::class,
],
],Each panel is a key in the panels array, where:
- Key - unique panel identifier (e.g.,
admin,test) - Value - array of panel settings
Inside a panel you can override any parameter from the top-level MoonShine configuration:
'panels' => [
'admin' => [
'prefix' => '', // URL prefix (optional)
'title' => 'Admin Panel', // Panel title
'layout' => AdminLayout::class, // Custom layout
'palette' => BluePalette::class, // Color scheme
'logo' => '/images/admin-logo.png',
'logo_small' => '/images/admin-logo-small.png',
// ... any other settings from moonshine.php
],
'client' => [
'prefix' => 'client',
'title' => 'Client Area',
'layout' => ClientLayout::class,
'palette' => GreenPalette::class,
// ... settings for client panel
],
],Important:
- If a parameter is not specified in the panel, the default value from the top-level configuration is used
- If
prefixis not specified, the panel key is used as the prefix - You can set
prefix => ''for a panel without prefix (root URL)
To make a resource appear only in a specific panel, extend MultiPanelResource and specify the $panel property:
<?php
namespace App\MoonShine\Resources;
use MoonShine\MultiPanels\MultiPanelResource;
class CarResource extends MultiPanelResource
{
protected string $panel = 'test';
// ... rest of the resource code
}Similarly for pages, use MultiPanelPage:
<?php
namespace App\MoonShine\Pages;
use MoonShine\MultiPanels\MultiPanelPage;
class Components extends MultiPanelPage
{
protected string $panel = 'test';
// ... rest of the page code
}You can create a unique layout for each panel:
- Create a custom Layout class:
<?php
namespace App\MoonShine\Layouts;
use MoonShine\Laravel\Layouts\AppLayout;
class ClientLayout extends AppLayout
{
protected function getMenu(): array
{
return [
// Your custom menu for client panel
];
}
}- Specify it in the panel configuration:
'panels' => [
'client' => [
'prefix' => 'client',
'layout' => ClientLayout::class,
// ...
],
],// config/moonshine.php
'panels' => [
'admin' => [
'prefix' => 'admin',
'title' => 'Admin Panel',
'layout' => AdminLayout::class,
'palette' => BluePalette::class,
],
'client' => [
'prefix' => 'client',
'title' => 'Client Area',
'layout' => ClientLayout::class,
'palette' => GreenPalette::class,
],
],URLs:
https://yourdomain.com/admin- admin panelhttps://yourdomain.com/client- client panel
'panels' => [
'superadmin' => [
'prefix' => '', // root URL
'title' => 'Super Admin',
'palette' => RedPalette::class,
],
'manager' => [
'prefix' => 'manager',
'title' => 'Manager Panel',
'palette' => OrangePalette::class,
],
'support' => [
'prefix' => 'support',
'title' => 'Support Panel',
'palette' => BluePalette::class,
],
],- Each panel works as an independent MoonShine application
- Resources and pages are bound to a specific panel via the
$panelproperty - Panel configuration overrides global MoonShine settings
- Routes are built automatically based on the panel prefix
- The
MultiPanelMiddlewaredetermines the current panel and applies its settings
If not registered automatically, add MultiPanelServiceProvider in bootstrap/providers.php:
return [
App\Providers\AppServiceProvider::class,
MoonShine\MultiPanels\Providers\MultiPanelServiceProvider::class,
],