Skip to content

Commit 498a35d

Browse files
authored
Merge pull request #103 from mindletic/master
2 parents f0c22a7 + 352e0ce commit 498a35d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ Please make sure to pass instance Model or Nova Resource ``Impersonate::make($th
114114
return $this->can_be_impersonated == 1;
115115
}
116116
```
117+
118+
By default `name` field is used for when displaying what user is impersonated at a moment.
119+
You need to add the method `impersonateName()` to your user model to extend this behavior:
120+
Please make sure to pass instance Model or Nova Resource ``Impersonate::make($this)`` ``Impersonate::make($this->resource)``
121+
122+
```php
123+
/**
124+
* @return string
125+
*/
126+
public function impersonateName()
127+
{
128+
// For example
129+
return $this->email;
130+
}
131+
```
117132
---
118133

119134
#### Events

resources/views/reverse.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"
2727
>
2828
<p>
29-
@if( auth($impersonatorGuardName)->user()->name )
29+
@if(method_exists(auth($impersonatorGuardName)->user(), 'impersonateName'))
30+
{{ __('Impersonating as') }} {{ auth($impersonatorGuardName)->user()->impersonateName() }}
31+
@elseif( auth($impersonatorGuardName)->user()->name )
3032
{{ __('Impersonating as') }} {{ auth($impersonatorGuardName)->user()->name }}
3133
@endif
3234
</p>

0 commit comments

Comments
 (0)