PHP code example of bezhansalleh / filament-panel-switch

1. Go to this page and download the library: Download bezhansalleh/filament-panel-switch library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bezhansalleh / filament-panel-switch example snippets


use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    // Custom configurations go here
});

          use BezhanSalleh\PanelSwitch\PanelSwitch;

          PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
              $panelSwitch->modalHeading('Available Panels');
          });
      

          use BezhanSalleh\PanelSwitch\PanelSwitch;

          PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
              $panelSwitch->modalWidth('sm');
          });
      

            use BezhanSalleh\PanelSwitch\PanelSwitch;
        
            PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
                $panelSwitch->slideOver();
            });
        

        use BezhanSalleh\PanelSwitch\PanelSwitch;
    
        PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
            $panelSwitch->simple();
        });
    

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch
        ->labels([
            'admin' => 'Custom Admin Label',
            'general_manager' => __('General Manager')
        ]);
});

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {    
    $panelSwitch->icons([
        'validPanelId1' => 'heroicon-o-square-2-stack',
        'validPanelId2' => 'heroicon-o-star',
    ], $asImage = false);
});

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {    
    $panelSwitch->icons([
        'validPanelId1' => 'https://raw.githubusercontent.com/bezhanSalleh/filament-panel-switch/3.x/art/banner.jpg',
        'validPanelId2' => 'https://raw.githubusercontent.com/bezhanSalleh/filament-panel-switch/3.x/art/banner.jpg',
    ], $asImage = true);
});

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {   
    // This would result in an icon/image size of 128 pixels.
    $panelSwitch->iconSize(32);  
});

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) { 
    $panelSwitch
        ->visible(fn (): bool => auth()->user()?->hasAnyRole([
            'admin',
            'general_manager',
            'super_admin',
        ]));
});

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch
        ->canSwitchPanels(fn (): bool => auth()->user()?->can('switch_panels'));
});

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch->panels([
        'admin',
        'dev',
        'app'
    ]);
});

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch
        ...
        ->panels(['admin', 'dev', 'app']) // default order if `sort()` method not used 
        ->sort() // ['admin', 'app', 'dev']
        // ->sort(order: 'desc') // ['dev', 'app', 'admin']
        ...
        ;
});

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch->renderHook('panels::global-search.after');
});

use BezhanSalleh\PanelSwitch\PanelSwitch;

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch
        ->panels(['admin', 'app', 'dev'])
        ->heading('Available Panels')
        ->modalWidth('sm')
        ->slideOver()
        ->icons([
            'admin' => 'heroicon-o-square-2-stack',
            'app' => 'heroicon-o-star',
        ])
        ->iconSize(16)
        ->labels([
            'admin' => 'Admin Panel',
            'app' => 'SaaS Application'
        ]);
        
});

export default {
    content: [
        // ...
        './vendor/bezhansalleh/filament-panel-switch/resources/views/panel-switch-menu.blade.php',
    ],
    // ...
}

PanelSwitch::configureUsing(function (PanelSwitch $panelSwitch) {
    $panelSwitch->excludes([
        'saas'
    ]);
});

"    "bezhansalleh/filament-panel-switch": "dev-fix/error-message as main-dev",
},
"repositories": [
    {
        "type": "path",
        "url": "filament-panel-switch"
    }
]
bash
php artisan vendor:publish --tag="filament-panel-switch-views"