Skip to content

Commit

Permalink
Handled empty array for entity
Browse files Browse the repository at this point in the history
  • Loading branch information
vinodraut committed Jun 8, 2018
1 parent 997ef81 commit 15100a6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/YesAuthority.php
Original file line number Diff line number Diff line change
Expand Up @@ -1418,8 +1418,6 @@ public function checkEntity($entityKey, $entityId, $requestForUserId = null)
throw new Exception('YesAuthority - Entity model does not exist.');
}

$this->requestCheckStringId .= '_cee_'. $entityKey . '_'. $entityId . '_' . $requestForUserId;

$this->entityPermissions = [];

// check if entity available as array
Expand All @@ -1439,6 +1437,13 @@ public function checkEntity($entityKey, $entityId, $requestForUserId = null)
// if entity model found
$this->entityIdentified = $entityFound->toArray();
}

if(empty($this->entityIdentified)) {
return $this;
}

$this->requestCheckStringId .= '_cee_'. $entityKey . '_'. $this->entityIdentified[$entityIdColumn] . '_' . $requestForUserId;

// get the permissions out of it
$rawEntityPermissions = array_get($this->entityIdentified, $permissionColumn);

Expand Down

0 comments on commit 15100a6

Please sign in to comment.