Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0247932

Browse files
committed
Guard - Add method 'id' for retrieve the current user id
1 parent 235d729 commit 0247932

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/Illuminate/Auth/Guard.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,25 @@ public function user()
148148

149149
return $this->user = $user;
150150
}
151+
152+
/**
153+
* Get the currently user id.
154+
*
155+
* @return int|null
156+
*/
157+
public function id()
158+
{
159+
if ($this->loggedOut) return;
160+
161+
$id = $this->session->get($this->getName());
162+
163+
if (!$id)
164+
{
165+
$id = $this->getRecaller();
166+
}
167+
168+
return $id;
169+
}
151170

152171
/**
153172
* Pull a user from the repository by its recaller ID.

0 commit comments

Comments
 (0)