PHP code example of xlite-dev / filament-impersonate
1. Go to this page and download the library: Download xlite-dev/filament-impersonate 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/ */
xlite-dev / filament-impersonate example snippets
use Packstub\AccountSwitcher\Concerns\HasLinkedAccounts;
class User extends Authenticatable implements FilamentUser
{
use HasLinkedAccounts;
public function canImpersonate(User $target): bool
{
return $this->hasRole('super-admin');
}
}
use Packstub\AccountSwitcher\AccountSwitcherPlugin;
$panel->plugin(
AccountSwitcherPlugin::make()
->developerLogins(['[email protected]', '[email protected]']),
);
// Or link programmatically — one click down, password up
$admin->linkAccount($daily, label: 'Daily',
use Packstub\AccountSwitcher\Filament\Actions\ImpersonateAction;
->recordActions([
ImpersonateAction::make(),
])
AccountSwitcherPlugin::make()
->impersonation() // on by default
->linkedAccounts() // on by default
->developerLogins(['[email protected]']) // off by default
->canImpersonateUsing(fn (User $by, User $target) => $by->can('impersonate', $target))
->canSwitchUsing(fn (User $from, User $to) => ! $to->is_locked)
->banner(position: 'top', style: 'light')
->redirectTo('/admin')
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.