Skip to content

Commit

Permalink
Little Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SupianIDz committed Sep 24, 2021
1 parent 1aa8f2b commit 7b936ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ $ composer require octopyid/laravel-impersonate:^2
$ artisan vendor:publish --provider="Octopy\LaraPersonate\ImpersonateServiceProvider"
```

> Sometimes some users experience the problem of layout after upgrading the package, this can be solved by deleting the `public/vendor/octopyid/impersonate` folder then republish the assets.
Add the trait `Octopy\LaraPersonate\Models\Impersonate` to your **User** model.
Expand Down Expand Up @@ -60,8 +61,8 @@ To limit the users who can **impersonate**. Add `canImpersonate()` to the **User
*/
public function canImpersonate() : bool
{
// example
return $this->is_admin === 1;
// example usage with laratrust package
return $this->hasRole('super-admin');
}
```

Expand All @@ -73,8 +74,10 @@ To limit which users can be **impersonated** by other users, for example super a
*/
public function canBeImpersonated() : bool
{
// example
return $this->can_be_impersonated === 1;
// example usage with laratrust package
return $this->hasRole([
'merchant', 'other-role'
]);
}
```

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
}
],
"require": {
"php": "^7.4|^8.0",
"laravel/framework": "^7"
"php": "^7.4|^8.0"
},
"require-dev": {
"orchestra/testbench": "^5|^6"
Expand Down
10 changes: 5 additions & 5 deletions resources/views/impersonate.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<div class="impersonate-info-line">
<table>
<tr>
<td class="impersonate-bold">Impersonated</td>
<td class="impersonate-bold">IMPERSONATED</td>
<td class="impersonate-bold">:</td>
<td>{{ $impersonate->getDisplayNameNextUser() }}</td>
</tr>
<tr>
<td class="impersonate-bold">Impersonating</td>
<td class="impersonate-bold">IMPERSONATING</td>
<td class="impersonate-bold">:</td>
<td>{{ $impersonate->getDisplayNamePrevUser() }}</td>
</tr>
Expand All @@ -51,17 +51,17 @@
@if($impersonate->impersonated())
<div class="impersonate-footer">
<div class="impersonate-logout">
<a href="#">&#10007; Leave</a>
<a href="#">&#10007; LEAVE</a>
</div>

<div class="impersonate-version">
version :
VERSION :
<a href="https://github.com/OctopyID/LaraPersonate">
{{ \Octopy\LaraPersonate\Impersonate::VERSION }}
</a>
</div>
</div>
@endif
@endif
</div>
</div>

Expand Down
3 changes: 2 additions & 1 deletion src/Impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Impersonate
/**
* @var string
*/
public const VERSION = 'v2.0.7';
public const VERSION = 'v2.0.8';

/**
* @var string
Expand Down Expand Up @@ -180,6 +180,7 @@ public function impersonated() : bool
/**
* @return bool
* @noinspection PhpPossiblePolymorphicInvocationInspection
* @throws MissingImpersonateTraitException
*/
public function authorized() : bool
{
Expand Down

0 comments on commit 7b936ce

Please sign in to comment.