alp-develop/laravel-livewire-panel
Laravel admin panel framework powered by Livewire (v3/v4). Supports Bootstrap 4/5 and Tailwind CSS, with an installer for URL prefix, navigation mode, auth/gates, registration, optional CDN libs, and publishable views. Compatible with Laravel 10–13.
## Getting Started
### Minimal Steps to First Use
1. **Installation**:
```bash
composer require alp-develop/laravel-livewire-panel
php artisan panel:install --defaults
admin prefix, Spatie gate driver).Create a Livewire Component:
php artisan make:livewire Dashboard
Update the generated component (app/Livewire/Dashboard.php):
use Livewire\Attributes\Layout;
#[Layout('panel::layouts.app')]
class Dashboard extends Component { ... }
Register the Route:
// routes/web.php
use AlpDevelop\LivewirePanel\Http\Middleware\PanelAuthMiddleware;
Route::middleware(['web', PanelAuthMiddleware::class])
->prefix('admin')
->name('panel.admin.')
->group(function () {
Route::get('/', \App\Livewire\Dashboard::class)->name('home');
});
Access the Panel:
Visit /admin/login to authenticate, then /admin to see your dashboard wrapped in the admin panel layout.
StatsCard widget to display metrics:
// app/Livewire/Dashboard.php
use AlpDevelop\LivewirePanel\Widgets\StatsCard;
public function render()
{
return view('livewire.dashboard', [
'widgets' => [
StatsCard::make()
->title('Users')
->value('1,234')
->icon('users')
->color('primary'),
],
]);
}
/admin to see the widget rendered in the dashboard grid.Products) with:
php artisan panel:make-module Products
app/Livewire/Panel/Modules/Products/ProductsModule.phpresources/views/panel/modules/products/...config/panel.php under modules.admin.// ProductsModule.php
public function widgets(): array
{
return [
\App\Livewire\Panel\Widgets\ProductStats::class,
];
}
config/panel.php:
'navigation' => [
'admin' => [
'items' => [
['label' => 'Dashboard', 'route' => 'panel.admin.home'],
['label' => 'Products', 'route' => 'panel.admin.products.index'],
],
],
],
// ProductsModule.php
public function navigation(): array
{
return [
'label' => 'Products',
'icon' => 'box',
'route' => 'panel.admin.products.index',
'children' => [
['label' => 'List', 'route' => 'panel.admin.products.index'],
['label' => 'Create', 'route' => 'panel.admin.products.create'],
],
];
}
resources/css/panel.css:
:root {
--panel-primary: #6366f1;
--panel-sidebar-bg: #1f2937;
}
<x-panel::dark-mode-toggle />
resources/views/panel/layouts/app.blade.php):
@extends('panel::layouts.app')
@section('sidebar')
@parent
<div class="p-4">
<x-panel::card>
Custom Sidebar Content
</x-panel::card>
</div>
@endsection
// config/panel.php
'gates' => [
'admin' => [
'driver' => 'spatie',
'model' => \App\Models\User::class,
],
],
PanelAuthMiddleware:
Route::middleware([PanelAuthMiddleware::class])->group(...);
use AlpDevelop\LivewirePanel\Facades\Panel;
public function mount()
{
$this->authorize('view-dashboard', Panel::current());
}
php artisan panel:make-plugin Analytics
app/Plugins/Panel/AnalyticsPlugin.phpresources/views/panel/plugins/analytics/...config/panel.php under plugins.// AnalyticsPlugin.php
public function registerNavigation(): array
{
return [
'label' => 'Analytics',
'icon' => 'chart-bar',
'route' => 'panel.admin.analytics',
];
}
public function registerWidgets(): array
{
return [
\App\Livewire\Panel\Widgets\AnalyticsChart::class,
];
}
Ctrl+K (default). Add providers:
// config/panel.php
'search' => [
'admin' => [
'providers' => [
\App\Providers\Panel\ProductSearchProvider::class,
],
],
],
use AlpDevelop\LivewirePanel\Contracts\SearchProviderInterface;
class ProductSearchProvider implements SearchProviderInterface
{
public function search(string $query): array
{
return Product::where('name', 'like', "%{$query}%")
->limit(15)
->get()
->map(fn ($product) => [
'label' => $product->name,
'route' => route('panel.admin.products.show', $product),
]);
}
}
config/panel.php:
'notifications' => [
'admin' => [
'polling' => true,
'providers' => [
\App\Providers\Panel\UnreadMessagesProvider::class,
],
],
],
use AlpDevelop\LivewirePanel\Contracts\NotificationProviderInterface;
class UnreadMessagesProvider implements NotificationProviderInterface
{
public function count(): int
{
return auth()->user()->unreadNotifications->count();
}
public function items(): array
{
return auth()->user()->unreadNotifications->take(10)->map(...);
}
}
config/panel.php:
'panels' => [
'admin' => ['prefix' => 'admin', 'theme' => 'bootstrap5'],
'shop' => ['prefix' => 'shop', 'theme' => 'tailwind'],
],
Panel::for('shop') to switch contexts in code.#[Layout('panel::layouts.app')] for panel pages.sidebar, navbar) via Blade @section directives.// app/Providers/PanelServiceProvider.php
public function boot()
{
Panel::widgets()->add(
\App\Livewire\Panel\Widgets\CustomWidget::class
);
}
config/panel.php:
'cdn' => [
'chartjs' => true,
'select2' => true,
],
php artisan vendor:publish --tag=panel-assets
<x-panel::locale-selector />
resources/lang/{locale}/panel.php:
return [
'custom_key' => 'Custom Value',
];
How can I help you explore Laravel packages today?