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 Larakit Adminlte Laravel Package

larakit/laravel-larakit-adminlte

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require larakit/laravel-larakit-adminlte
    

    Publish the package assets and config:

    php artisan vendor:publish --provider="Larakit\AdminLTE\AdminLTEServiceProvider" --tag="public"
    php artisan vendor:publish --provider="Larakit\AdminLTE\AdminLTEServiceProvider" --tag="config"
    
  2. Basic Usage Add the middleware to your app/Http/Kernel.php:

    protected $middlewareGroups = [
        'web' => [
            // ...
            \Larakit\AdminLTE\Middleware\CheckForAdminLTE::class,
        ],
    ];
    
  3. First Admin Page Create a route in routes/web.php:

    Route::get('/admin/dashboard', function () {
        return view('adminlte::dashboard');
    });
    
  4. Customize Layout Override the default layout by publishing views:

    php artisan vendor:publish --provider="Larakit\AdminLTE\AdminLTEServiceProvider" --tag="views"
    

    Modify resources/views/vendor/adminlte/layouts/app.blade.php to fit your branding.


First Use Case: Quick Admin Panel

  • Use the built-in dashboard view (adminlte::dashboard) as a starting point.
  • Extend the layout with your own partials (e.g., resources/views/partials/admin/sidebar.blade.php).
  • Leverage the widgets system for reusable UI components:
    use Larakit\AdminLTE\Widgets\Widget;
    
    Widget::box('Box Title', 'Box Content')->style('blue')->render();
    

Implementation Patterns

Core Workflows

  1. Layout Customization

    • Override the default layout (app.blade.php) and partials (sidebar, navbar, footer).
    • Use @stack and @include to inject dynamic content:
      @include('admin.partials.sidebar')
      @stack('scripts')
      
  2. Dynamic Sidebars

    • Use the sidebar() helper to generate dynamic sidebars:
      sidebar()
          ->add('Dashboard', 'dashboard', 'fa fa-dashboard')
          ->add('Users', 'users.index', 'fa fa-users')
          ->render();
      
    • Store sidebar items in a config file (config/adminlte.php) for reusability.
  3. Widgets and Boxes

    • Create reusable widgets in controllers or service providers:
      Widget::box('Stats', $statsData)
          ->style('green')
          ->icon('fa fa-chart-bar')
          ->render();
      
    • Use widget stacks to group related widgets:
      @widgetStack('stats')
      
  4. Authentication

    • Extend the default auth views (login.blade.php, register.blade.php) by publishing them:
      php artisan vendor:publish --provider="Larakit\AdminLTE\AdminLTEServiceProvider" --tag="auth-views"
      
    • Customize the login page with your branding (logo, background, etc.).

Integration Tips

  1. Blade Directives

    • Use @adminLTE directives for common tasks:
      @adminLTE
          @sidebar
              @item('Dashboard', 'dashboard', 'fa fa-dashboard')
          @endsidebar
      @endadminLTE
      
  2. JavaScript and CSS

    • Load AdminLTE assets globally via app.blade.php or conditionally in views:
      @push('styles')
          <link rel="stylesheet" href="{{ asset('vendor/adminlte/plugins/chartjs/Chart.min.css') }}">
      @endpush
      
  3. Multi-Tenancy

    • Dynamically adjust the layout (e.g., sidebar, theme) based on the authenticated user:
      $sidebar = sidebar()->addTenancyAwareItems($user->tenancyItems());
      
  4. Localization

    • Override translations in resources/lang/{locale}/adminlte.php:
      return [
          'sidebar' => [
              'dashboard' => 'Приборная панель',
          ],
      ];
      

Gotchas and Tips

Common Pitfalls

  1. Middleware Conflicts

    • Ensure CheckForAdminLTE middleware is placed after auth middleware in Kernel.php to avoid redirect loops.
    • If using API routes, exclude them from the middleware group:
      protected $middlewareGroups = [
          'web' => [
              // ...
              \Larakit\AdminLTE\Middleware\CheckForAdminLTE::class,
          ],
          'api' => [
              // No AdminLTE middleware here
          ],
      ];
      
  2. Asset Loading Issues

    • If CSS/JS fails to load, verify the public publish step was run and assets are linked correctly in app.blade.php:
      <link rel="stylesheet" href="{{ asset('vendor/adminlte/dist/css/adminlte.min.css') }}">
      
    • Clear cached views and config:
      php artisan view:clear
      php artisan config:clear
      
  3. Sidebar Item Routing

    • Ensure sidebar items use named routes or URL helpers for consistency:
      ->add('Users', route('users.index'), 'fa fa-users')
      
    • Avoid hardcoding URLs (e.g., /admin/users) to prevent route caching issues.
  4. Theme Switching

    • AdminLTE themes (e.g., skin-blue, skin-black) are applied via the data-skin attribute in app.blade.php. Override this dynamically:
      <body class="hold-transition {{ config('adminlte.skin') }}">
      

Debugging Tips

  1. View Overrides

    • If changes to published views don’t reflect, clear the view cache:
      php artisan view:clear
      
    • Use php artisan vendor:publish --tag=views --force to republish views.
  2. Widget Debugging

    • Enable debug mode for widgets to log output:
      Widget::debug(true); // Add to a service provider's boot method
      
    • Check for missing dependencies (e.g., jQuery, Bootstrap) in the browser console.
  3. Configuration

    • Validate config/adminlte.php for typos or incorrect paths. Use:
      php artisan config:dump
      
    • Reset config to defaults:
      php artisan vendor:publish --provider="Larakit\AdminLTE\AdminLTEServiceProvider" --tag="config" --force
      

Extension Points

  1. Custom Widgets

    • Extend the Widget class to create domain-specific widgets:
      namespace App\Widgets;
      
      use Larakit\AdminLTE\Widgets\Widget;
      
      class UserStatsWidget extends Widget {
          public function __construct($data) {
              parent::__construct('User Stats', $data);
              $this->style('purple')->icon('fa fa-users');
          }
      }
      
  2. Dynamic Layouts

    • Use view composers to inject dynamic data into the layout:
      view()->composer('adminlte::layouts.app', function ($view) {
          $view->with('dynamicSidebar', $this->getSidebarItems());
      });
      
  3. Plugin Integration

    • Integrate third-party plugins (e.g., DataTables, Select2) by:
      • Publishing their assets:
        php artisan vendor:publish --tag=datatables-assets
        
      • Including them in app.blade.php or specific views:
        @push('scripts')
            <script src="{{ asset('vendor/datatables/js/jquery.dataTables.min.js') }}"></script>
        @endpush
        
  4. Event Listeners

    • Listen for AdminLTE events (e.g., AdminLTEInitialized) to hook into the initialization process:
      Event::listen('AdminLTEInitialized', function () {
          // Modify the layout or add global data
      });
      
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware