forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionRepository.php
More file actions
43 lines (38 loc) · 1.04 KB
/
SessionRepository.php
File metadata and controls
43 lines (38 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Pterodactyl\Repositories\Eloquent;
use Pterodactyl\Models\Session;
use Illuminate\Support\Collection;
use Pterodactyl\Contracts\Repository\SessionRepositoryInterface;
class SessionRepository extends EloquentRepository implements SessionRepositoryInterface
{
/**
* Return the model backing this repository.
*
* @return string
*/
public function model()
{
return Session::class;
}
/**
* Return all of the active sessions for a user.
*
* @param int $user
* @return \Illuminate\Support\Collection
*/
public function getUserSessions(int $user): Collection
{
return $this->getBuilder()->where('user_id', $user)->get($this->getColumns());
}
/**
* Delete a session for a given user.
*
* @param int $user
* @param string $session
* @return null|int
*/
public function deleteUserSession(int $user, string $session)
{
return $this->getBuilder()->where('user_id', $user)->where('id', $session)->delete();
}
}