Skip to content

Commit f0018d3

Browse files
mnabialekbarryvdh
authored andcommitted
Allow to use nullable user (barryvdh#786)
1 parent b5d1df3 commit f0018d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/DataCollector/GateCollector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ public function __construct(Gate $gate)
2525
$gate->after([$this, 'addCheck']);
2626
}
2727

28-
public function addCheck(Authorizable $user, $ability, $result, $arguments = [])
28+
public function addCheck(Authorizable $user = null, $ability, $result, $arguments = [])
2929
{
3030
$label = $result ? 'success' : 'error';
3131

3232
$this->addMessage([
3333
'ability' => $ability,
3434
'result' => $result,
35-
snake_case(class_basename($user)) => $user->id,
35+
($user ? snake_case(class_basename($user)) : 'user') => ($user ? $user->id : null),
3636
'arguments' => $this->exporter->cloneVar($arguments),
3737
], $label, false);
3838
}

0 commit comments

Comments
 (0)