Skip to content

Commit

Permalink
Check if key is set (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh authored Oct 18, 2024
1 parent f5c4011 commit a4e6909
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/DataCollector/GateCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ public function addCheck($user, $ability, $result, $arguments = [])
if (isset($arguments[0])) {
if ($arguments[0] instanceof Model) {
$model = $arguments[0];
$target = get_class($model) . '(' . $model->getKeyName() .'=' . $model->getKey().')';
if ($model->getKeyName() && $model->hasAttribute($model->getKeyName())) {
$target = get_class($model) . '(' . $model->getKeyName() . '=' . $model->getKey() . ')';
} else {
$target = get_class($model);
}
} else if (is_string($arguments[0])) {
$target = $arguments[0];
}
Expand Down

0 comments on commit a4e6909

Please sign in to comment.