404labfr / 404labfr/laravel-impersonate

Blade macro for both canImpersonate and canBeImpersonated

Open
#152 0 comments 1 reaction 0 assignees View on GitHub
enhancement good first issue
Dominant language
PHP
Stars
2.3k
Forks
235
PR merge metrics
No merged PRs in 30d

Description

Is there a cleaner way of checking both?
```
@foreach($users as $user)
@canImpersonate()
@canBeImpersonated($user)
Impersonate this user
@endCanBeImpersonated
@endCanImpersonate
@endforeach
```

User model I only want super admin to be able to impersonate.
```php
/**
* Allow authenticate of another users
* @return bool
*/
public function canImpersonate()
{
return $this->isSuperAdmin();
}

/**
* Allow authenticate of this user
* @return bool
*/
public function canBeImpersonated()
{
return !$this->isSuperAdmin();
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.