A comprehensive admin panel for Laravel with authentication and content management
statisticlv/laravel-admin-panel is a Laravel package for a comprehensive admin panel for laravel with authentication and content management.
It currently has 0 GitHub stars and 14 downloads on Packagist.
Install it with composer require statisticlv/laravel-admin-panel.
Discover more Laravel packages by statisticlv
or browse all Laravel packages to compare alternatives.
Last updated
A comprehensive admin panel package for Laravel with authentication, content management, and frontend integration. This package provides a complete CMS solution with news management, pages, menus, settings, and a built-in frontend.
Current Version: 1.0.0
composer require statisticlv/laravel-admin-panel
Run the installation command to publish all necessary files:
php artisan admin-panel:install
The installation command will:
config/admin-panel.phpapp/Http/Controllers/routes/web.phpresources/views/public/vendor/admin-panel/To install with sample data for testing:
php artisan admin-panel:install --demo
Demo credentials:
After installation, you can customize the package by editing config/admin-panel.php:
return [
// Admin panel route prefix
'route_prefix' => 'admin',
// Middleware applied to admin routes
'middleware' => ['web'],
// Enable default frontend routes
'enable_frontend_routes' => true,
// Authentication guard
'guard' => 'admin',
// Admin panel title
'title' => 'Admin Panel',
// Items per page in list views
'per_page' => 15,
// Default date format
'date_format' => 'Y-m-d H:i:s',
];
Create a new admin user via command line:
php artisan admin:create-user
Options:
--name - The name of the admin user--email - The email of the admin user--password - The password for the admin user--role - The role (admin or super_admin, default: admin)Example:
php artisan admin:create-user --name="John Doe" --email="[email protected]" --password="SecurePass123" --role="super_admin"
The package creates the following tables:
admin_users - Admin user accounts with roles and statusnews - News articles with status, author, and view countspages - Static pages with templates and SEO metadatamenus - Menu definitions with locationsmenu_items - Individual menu items with support for nestingsettings - Dynamic key-value settings with groupingAdmin user model with role-based access control.
use StatisticLv\AdminPanel\Models\AdminUser;
// Check if user is super admin
$user->isSuperAdmin(); // bool
// Check if user is admin (regular or super)
$user->isAdmin(); // bool
// Get news articles by author
$user->news;
News article model with publishing workflow.
use StatisticLv\AdminPanel\Models\News;
// Get published news
$publishedNews = News::published()->get();
// Get draft news
$draftNews = News::draft()->get();
// Check if published
$news->isPublished(); // bool
// Increment view count
$news->incrementViews();
Page model with SEO support.
use StatisticLv\AdminPanel\Models\Page;
// Get published pages
$pages = Page::published()->get();
// Get meta title (falls back to title)
$page->meta_title;
// Get meta description (falls back to excerpt)
$page->meta_description;
Menu management with nested structure.
use StatisticLv\AdminPanel\Models\Menu;
$menu = Menu::where('slug', 'main')->first();
// Get root items only
$items = $menu->items;
// Get all items including nested
$allItems = $menu->allItems;
Dynamic settings management.
use StatisticLv\AdminPanel\Models\Setting;
// Get a setting value
$value = Setting::getValue('site_name', 'Default Name');
// Set a setting value
Setting::setValue('site_name', 'My Site');
// Get all settings grouped
$groupedSettings = Setting::getAllGrouped();
// Get all settings as array
$settingsArray = Setting::getAllAsArray();
The package provides global helper functions for easy access to data:
// Get a menu by identifier
$menu = admin_menu('main');
// Render a menu as HTML
echo admin_render_menu('main', 'slug', ['class' => 'nav-menu']);
// Get published news
$news = admin_news($limit = 10, $paginate = 15);
// Get news by slug
$article = admin_news_by_slug('my-article');
// Get latest news
$latest = admin_latest_news(5);
// Get popular news
$popular = admin_popular_news(5);
// Get page by slug
$page = admin_page_by_slug('about-us');
// Get all published pages
$pages = admin_pages($limit = 10);
// Format date
$formattedDate = admin_format_date($date, 'Y-m-d');
// Truncate text
$truncated = admin_truncate($text, 100, '...');
// Get excerpt from HTML
$excerpt = admin_excerpt($htmlContent, 200);
GET /admin/login - Login pagePOST /admin/login - Login actionPOST /admin/logout - Logout actionGET /admin - DashboardGET /admin/dashboard - DashboardGET|POST|PUT|DELETE /admin/news - News management (CRUD)GET|POST|PUT|DELETE /admin/pages - Page management (CRUD)GET|POST|PUT|DELETE /admin/menus - Menu management (CRUD)POST /admin/menus/{menu}/items - Add menu itemPUT /admin/menus/{menu}/items/{item} - Update menu itemDELETE /admin/menus/{menu}/items/{item} - Delete menu itemGET|POST|PUT|DELETE /admin/settings - Settings managementGET|POST|PUT|DELETE /admin/users - User management (CRUD, Super Admin only)POST /admin/users/{user}/restore - Restore soft-deleted user (Super Admin only)DELETE /admin/users/{user}/force-delete - Permanently delete user (Super Admin only)GET / - HomepageGET /news - News listingGET /news/{slug} - Single news articleGET /{slug} - Page (catch-all route)The package uses a separate authentication guard for admin users:
// Authenticate admin user
if (Auth::guard('admin')->attempt($credentials)) {
// Success
}
// Get authenticated admin user
$admin = Auth::guard('admin')->user();
// Check authentication
if (Auth::guard('admin')->check()) {
// User is authenticated
}
Two roles are available:
admin - Regular admin with standard permissions (news, pages, menus, settings)super_admin - Super admin with full permissions including user managementThe package includes the following middleware:
admin.auth - Authentication middleware for admin routessuper.admin - Authorization middleware for super admin only routes// Protect admin routes (requires authentication)
Route::middleware(['admin.auth'])->group(function () {
// Protected admin routes
});
// Protect super admin routes (requires super admin role)
Route::middleware(['super.admin'])->group(function () {
// Super admin only routes (e.g., user management)
});
The package publishes views to resources/views/:
auth/login.blade.php - Admin login pagedashboard/index.blade.php - Admin dashboardnews/index.blade.php - News listingnews/create.blade.php - Create news formnews/edit.blade.php - Edit news formpages/index.blade.php - Pages listingpages/create.blade.php - Create page formpages/edit.blade.php - Edit page formmenus/index.blade.php - Menus listingmenus/create.blade.php - Create menu formmenus/edit.blade.php - Edit menu formusers/index.blade.php - Users listing (Super Admin only)users/create.blade.php - Create user form (Super Admin only)users/edit.blade.php - Edit user form (Super Admin only)users/show.blade.php - User details view (Super Admin only)settings/index.blade.php - Settings listingsettings/edit.blade.php - Edit settings formfrontend/home.blade.php - Homepagefrontend/news/index.blade.php - News listing (frontend)frontend/news/show.blade.php - Single news article (frontend)frontend/pages/default.blade.php - Default page template (frontend)layouts/app.blade.php - Admin layoutfrontend/layouts/app.blade.php - Frontend layoutAfter installation, controllers are published to app/Http/Controllers/. You can modify them to add custom logic:
// app/Http/Controllers/NewsController.php
namespace App\Http\Controllers;
use StatisticLv\AdminPanel\Models\News;
class NewsController extends \StatisticLv\AdminPanel\Http\Controllers\NewsController
{
// Override methods or add new ones
}
All views are published to resources/views/ and can be customized as needed.
The web routes file is published to routes/web.php. You can modify routes or add new ones.
Run the included tests:
php artisan test
Tests cover:
This package is open-source software licensed under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
See CHANGELOG.md for version history and changes.