Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blade helper @canBeImpersonated #12

Closed
Konafets opened this issue Apr 4, 2017 · 3 comments
Closed

Add blade helper @canBeImpersonated #12

Konafets opened this issue Apr 4, 2017 · 3 comments

Comments

@Konafets
Copy link
Contributor

Konafets commented Apr 4, 2017

Hey,

in my user list I dont want to show the Impersonate button for admins. At the moment I do this:

@if((Auth::user()->id !== $user->id) && ($user->canBeImpersonated()))
    <a href="{{ route('impersonate', ['id' => $user->id]) }}" class="btn btn-xs btn-warning">Impersonate</a>
@endif

Unless I miss something, I think such a helper is a nice addition to this package.

@tghpow
Copy link
Member

tghpow commented Apr 4, 2017

Hi.

Did you add the trait Impersonate to your user model ?
Did you overwrite the canBeImpersonated() method ? How ?

@Konafets
Copy link
Contributor Author

Konafets commented Apr 4, 2017

Yes, I have the trait and the method overridden like so

/**
 * @return bool
 */
public function canBeImpersonated() : bool
{
    return !$this->isAdministrator();
}

Just to be clear, my code above works as intended. I just thought it would be nice to have a blade helper @canBeImpersonated for that.

@tghpow
Copy link
Member

tghpow commented Apr 4, 2017

Ah sorry, i read too fast..

It's a good idea, if you want do a pull request.
Otherwise, we will do it ourselves on the occasion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants