trf_certest/app/Support/CanImpersonateUsers.php
2025-02-26 08:57:46 +01:00

25 lines
550 B
PHP

<?php
namespace Vanguard\Support;
trait CanImpersonateUsers
{
/**
* Check if a user can impersonate other users.
*/
public function canImpersonate(): bool
{
return $this->hasPermission('users.manage');
}
/**
* Check if a target user can be impersonated.
* By default, all users can be impersonated if a currently logged
* user is not already impersonating another user.
*/
public function canBeImpersonated(): bool
{
return ! app('impersonate')->isImpersonating();
}
}