PHP code example of akira / filament-switch-panel

1. Go to this page and download the library: Download akira/filament-switch-panel 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/ */

    

akira / filament-switch-panel example snippets


use Akira\FilamentSwitchPanel\FilamentSwitchPanel;


FilamentSwitchPanel::configureUsing(function (FilamentSwitchPanel $switchPanel) {

	$switchPanel->modalHeading('Modal Heading')
	->modalWidth('md')
	->slideOver()
	->simple()
	->labels([
		'admin' => 'Admin',
		'user' => 'User',
	])
	->icons([
		'admin' => 'heroicon-o-user',
		'user' => 'heroicon-o-user',
	], $asImage = false)
	->iconSize(32)
	->visible(fn (): bool => auth()->user()?->hasAnyRole(['admin',]))
	->canSwitchPanels(fn (): bool => auth()->user()?->can('switch-panels'))
	->excludes(['user'])
	->renderHook('panels::global-search.before')

});

bash
php artisan vendor:publish --tag="filament-switch-panel-views"