Weave 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

Panel Laravel Package

mylaraveltools/panel

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. Installation

    composer require mylaraveltools/panel
    php artisan vendor:publish --provider="Mylaraveltools\Panel\PanelServiceProvider" --tag="panel-config"
    php artisan migrate
    
    • Check config/panel.php for basic configuration (e.g., panel_name, theme, auth_driver).
  2. Basic Setup

    • Publish the default Livewire panel view:
      php artisan vendor:publish --provider="Mylaraveltools\Panel\PanelServiceProvider" --tag="panel-views"
      
    • Register the panel route in routes/web.php:
      Route::panel(); // Default: `/panel`
      
  3. First Use Case: Quick Dashboard

    • Create a Livewire component (e.g., DashboardPanel) extending Mylaraveltools\Panel\Components\PanelComponent:
      namespace App\Http\Livewire;
      
      use Mylaraveltools\Panel\Components\PanelComponent;
      
      class DashboardPanel extends PanelComponent
      {
          public function render()
          {
              return view('livewire.dashboard-panel', [
                  'stats' => $this->getStats(), // Example method
              ]);
          }
      }
      
    • Register it in config/panel.php under panels.dashboard.

Implementation Patterns

Declarative Panel Structure

  • Define Panels in Config

    // config/panel.php
    'panels' => [
        'dashboard' => [
            'component' => \App\Http\Livewire\DashboardPanel::class,
            'icon' => 'home',
            'title' => 'Dashboard',
            'order' => 1,
        ],
        'users' => [
            'component' => \App\Http\Livewire\UsersPanel::class,
            'icon' => 'users',
            'title' => 'User Management',
            'order' => 2,
        ],
    ],
    
    • Dynamic Loading: Panels are auto-discovered via config. No manual route binding needed.
  • Livewire Integration

    • Extend PanelComponent for shared functionality (e.g., auth checks, layout):
      use Mylaraveltools\Panel\Traits\HasPanelPermissions;
      
      class UsersPanel extends PanelComponent
      {
          use HasPanelPermissions;
      
          public function rules()
          {
              return [
                  'view_users' => 'can:view-users',
              ];
          }
      }
      

Workflow: Adding a New Panel

  1. Create Livewire Component
    php artisan make:livewire Admin/PostsPanel
    
  2. Extend PanelComponent
    namespace App\Http\Livewire\Admin;
    
    use Mylaraveltools\Panel\Components\PanelComponent;
    
    class PostsPanel extends PanelComponent
    {
        public function render()
        {
            return view('livewire.admin.posts-panel', [
                'posts' => Post::latest()->get(),
            ]);
        }
    }
    
  3. Register in Config
    'posts' => [
        'component' => \App\Http\Livewire\Admin\PostsPanel::class,
        'icon' => 'file-alt',
        'title' => 'Posts',
        'order' => 3,
        'middleware' => ['verified'], // Optional
    ],
    
  4. Access via /panel/posts

Tailwind Styling

  • Predefined Classes: Use panel-* utilities (e.g., panel-bg-gray-800, panel-text-white).
  • Custom CSS: Override in resources/css/panel.css:
    @layer components.panel {
        .panel-header {
            @apply bg-gray-700;
        }
    }
    

Gotchas and Tips

Pitfalls

  1. Route Caching Conflicts

    • After adding new panels, clear routes:
      php artisan route:clear
      
    • Why? The panel routes are generated dynamically via Route::panel().
  2. Livewire Component Not Found

    • Ensure the FQCN in config/panel.php matches the autoloaded class.
    • Debug: Run composer dump-autoload if classes aren’t resolved.
  3. Permission Traits Not Loading

    • Verify HasPanelPermissions is used in the component and the rules() method is defined.
    • Fix: Check config/panel.php for auth_driver (e.g., spatie-permission).
  4. Tailwind Conflicts

    • If styles don’t apply, ensure @tailwindcss/directives is in resources/css/app.css and the panel layer is included:
      @tailwind base;
      @tailwind components;
      @tailwind utilities;
      
      @layer components.panel { ... }
      

Debugging Tips

  • Panel Not Showing?

    • Check storage/logs/laravel.log for missing component errors.
    • Verify the panel is listed in config/panel.php with a valid order value.
  • Livewire Updates Not Triggering

    • Add $this->emit('refreshPanel') in parent component methods to force UI updates.
  • Auth Issues

    • Test with php artisan panel:auth to generate a test user if using auth_driver: 'panel'.

Extension Points

  1. Custom Layouts Override the default panel layout by publishing views:

    php artisan vendor:publish --tag="panel-views" --force
    

    Then modify resources/views/vendor/panel/layouts/app.blade.php.

  2. Dynamic Panel Loading Use the PanelService to fetch panels programmatically:

    use Mylaraveltools\Panel\Facades\Panel;
    
    $panels = Panel::getPanels(); // Returns array of configured panels
    
  3. Multi-Tenancy Extend the PanelService to filter panels by tenant:

    Panel::getPanels()->where('tenant_id', auth()->tenant()->id);
    
  4. Dark Mode Enable via config:

    'theme' => [
        'dark_mode' => true,
        'dark_class' => 'dark',
    ],
    

    Then use dark: variants in Tailwind (e.g., dark:bg-gray-900).

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.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log