Skip to content

Commit a4e6909

Browse files
authored
Check if key is set (#1691)
1 parent f5c4011 commit a4e6909

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/DataCollector/GateCollector.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public function addCheck($user, $ability, $result, $arguments = [])
6464
if (isset($arguments[0])) {
6565
if ($arguments[0] instanceof Model) {
6666
$model = $arguments[0];
67-
$target = get_class($model) . '(' . $model->getKeyName() .'=' . $model->getKey().')';
67+
if ($model->getKeyName() && $model->hasAttribute($model->getKeyName())) {
68+
$target = get_class($model) . '(' . $model->getKeyName() . '=' . $model->getKey() . ')';
69+
} else {
70+
$target = get_class($model);
71+
}
6872
} else if (is_string($arguments[0])) {
6973
$target = $arguments[0];
7074
}

0 commit comments

Comments
 (0)