Skip to content

Commit

Permalink
Merge pull request #86 from BinaryKitten/fix/remove_superfluous_check
Browse files Browse the repository at this point in the history
Update Impersonate class for minor performance checks on each run/per row
  • Loading branch information
KABBOUCHI authored Jun 17, 2021
2 parents 8e67830 + cd5847c commit e5aab84
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ public function __construct($user = null)

$this->exceptOnForms();

if (method_exists(auth()->user(), 'canImpersonate') && ! auth()->user()->canImpersonate()) {
$authUser = auth()->user();
if (method_exists($authUser, 'canImpersonate') && ! $authUser->canImpersonate()) {
$this->component = null;

return;
}

if ($user != null) {
if ($user !== null) {
if (is_numeric($user) || is_string($user)) {
$this->withMeta(['id' => $user instanceof Model ? $user->getKey() : $user]);
$this->withMeta(['id' => $user]);
} else {
$user = $user instanceof Resource ? $user->resource : $user;

Expand Down

0 comments on commit e5aab84

Please sign in to comment.