Weave Code
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 Boilerplate Laravel Package

cendekia/laravel-admin-boilerplate

Laravel 5.x admin boilerplate package. Installs via Composer, publish vendor assets, adds a User→UserRole one-to-one relation, and (Laravel 5.4+) registers admin auth/logged middlewares in Kernel. Intended as a starting point for admin panels.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require cendekia/laravel-admin-boilerplate
    

    Publish the package assets and config:

    php artisan vendor:publish --provider="Cendekia\AdminBoilerplate\AdminBoilerplateServiceProvider" --tag="config"
    php artisan vendor:publish --provider="Cendekia\AdminBoilerplate\AdminBoilerplateServiceProvider" --tag="migrations"
    php artisan vendor:publish --provider="Cendekia\AdminBoilerplate\AdminBoilerplateServiceProvider" --tag="views"
    
  2. Run Migrations

    php artisan migrate
    
  3. Auth Setup Configure your auth driver in config/auth.php to use the admin guard (if not already set up). Update the users table migration to include is_admin column if needed.

  4. First Use Case Access /admin to see the default dashboard. The package provides a basic admin panel with:

    • User management (if users table is configured).
    • A simple CRUD interface for the posts table (if it exists).

Where to Look First

  • Config File: config/admin-boilerplate.php – Customize routes, middleware, and default settings.
  • Routes: routes/admin.php – Extend or override default admin routes.
  • Views: resources/views/vendor/admin-boilerplate/ – Override or extend Blade templates.
  • Middleware: app/Http/Middleware/AdminMiddleware.php – Modify admin access logic.

Implementation Patterns

1. Extending the Admin Panel

Use the AdminBoilerplate facade to register custom resources or dashboards:

use Cendekia\AdminBoilerplate\Facades\AdminBoilerplate;

// Register a new resource (e.g., for 'products' table)
AdminBoilerplate::resource('products', \App\Http\Controllers\Admin\ProductController::class);

// Register a custom dashboard widget
AdminBoilerplate::dashboardWidget(\App\Widgets\RecentOrders::class);

2. Creating Custom Controllers

Extend the base AdminController or use traits like CrudTrait for quick CRUD operations:

namespace App\Http\Controllers\Admin;

use Cendekia\AdminBoilerplate\Http\Controllers\AdminController;
use Cendekia\AdminBoilerplate\Traits\CrudTrait;

class ProductController extends AdminController
{
    use CrudTrait;

    protected $model = \App\Models\Product::class;
    protected $view = 'admin.products.index';
}

3. Customizing Views

Override default views by publishing them first, then modifying:

php artisan vendor:publish --tag="admin-boilerplate-views"

Edit files in resources/views/vendor/admin-boilerplate/.

4. Adding Middleware

Attach middleware to admin routes in config/admin-boilerplate.php:

'middleware' => [
    'auth.admin',
    'verified', // Example: Add email verification
],

5. Localization and Translations

Publish translations and customize language files:

php artisan vendor:publish --tag="admin-boilerplate-translations"

Edit resources/lang/vendor/admin-boilerplate/.

6. API Integration

Use the AdminBoilerplate facade to expose API endpoints for admin resources:

AdminBoilerplate::apiResource('products', \App\Http\Controllers\Admin\Api\ProductController::class);

Gotchas and Tips

Pitfalls

  1. Route Conflicts

    • Ensure routes/admin.php does not conflict with existing routes. Use prefix('admin') or namespace to isolate admin routes.
    • Fix: Clear cached routes after changes:
      php artisan route:clear
      
  2. Middleware Misconfiguration

    • If the auth.admin middleware fails, verify the admin guard is properly configured in config/auth.php.
    • Fix: Check app/Http/Middleware/AdminMiddleware.php for custom logic.
  3. Database Migrations

    • The package includes migrations for users and posts tables. If your schema differs, override them or create new migrations.
    • Tip: Use php artisan migrate:status to check pending migrations.
  4. View Overrides

    • Forgetting to publish views before editing can lead to missing template errors.
    • Fix: Always publish views first:
      php artisan vendor:publish --tag="admin-boilerplate-views"
      
  5. Caching Issues

    • Changes to Blade views or config may not reflect immediately due to Laravel’s caching.
    • Fix: Clear caches:
      php artisan view:clear
      php artisan config:clear
      

Debugging Tips

  • Log Admin Activity Enable logging in config/admin-boilerplate.php:

    'logging' => [
        'enabled' => true,
        'channel' => 'single',
    ],
    

    Check logs in storage/logs/laravel.log.

  • Dump Admin Routes Use Tinker to inspect admin routes:

    php artisan tinker
    >>> \Route::getRoutes()->getByName('admin.*')->get();
    
  • Test Middleware Temporarily disable middleware in config/admin-boilerplate.php to isolate issues:

    'middleware' => [],
    

Extension Points

  1. Custom Auth Providers Extend the AdminUser model or create a custom provider for admin authentication.

  2. Dynamic Permissions Integrate with packages like spatie/laravel-permission for role-based access:

    use Spatie\Permission\Traits\HasRoles;
    
    class AdminUser extends User
    {
        use HasRoles;
    }
    
  3. Event Listeners Listen to admin events (e.g., AdminBoilerplate\Events\ResourceCreated):

    AdminBoilerplate::listen('resource.created', function ($resource, $model) {
        // Custom logic after resource creation
    });
    
  4. API Resources Use Laravel’s ApiResource to customize API responses for admin endpoints.

  5. Custom Storage Override the default storage paths in config/admin-boilerplate.php:

    'storage' => [
        'uploads' => 'storage/app/admin_uploads',
    ],
    
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.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver