Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Repositories/Eloquent/SessionRepository.php
7460 views
1
<?php
2
3
namespace Pterodactyl\Repositories\Eloquent;
4
5
use Pterodactyl\Models\Session;
6
use Illuminate\Support\Collection;
7
use Pterodactyl\Contracts\Repository\SessionRepositoryInterface;
8
9
class SessionRepository extends EloquentRepository implements SessionRepositoryInterface
10
{
11
/**
12
* Return the model backing this repository.
13
*/
14
public function model(): string
15
{
16
return Session::class;
17
}
18
19
/**
20
* Return all the active sessions for a user.
21
*/
22
public function getUserSessions(int $user): Collection
23
{
24
return $this->getBuilder()->where('user_id', $user)->get($this->getColumns());
25
}
26
27
/**
28
* Delete a session for a given user.
29
*/
30
public function deleteUserSession(int $user, string $session): ?int
31
{
32
return $this->getBuilder()->where('user_id', $user)->where('id', $session)->delete();
33
}
34
}
35
36