PHP code example of bradietilley / laravel-impersonation
1. Go to this page and download the library: Download bradietilley/laravel-impersonation 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/ */
bradietilley / laravel-impersonation example snippets
use BradieTilley\Impersonation\Contracts\Impersonateable;
use BradieTilley\Impersonation\ImpersonationManager;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements Impersonateable
{
//
}
ImpersonationManager::configure(
authorize: fn ($admin, $user) => $admin->isAdmin() && ! $user->isAdmin(),
);
ImpersonationManager::make()->impersonate($user);
ImpersonationManager::make()->stopImpersonating();