2025-01-31 18:20:13 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-08-11 16:50:19 +03:00
|
|
|
namespace openvk\Web\Models\Entities;
|
2025-01-31 18:20:13 +03:00
|
|
|
|
2023-08-11 16:50:19 +03:00
|
|
|
use openvk\Web\Models\RowModel;
|
|
|
|
use openvk\Web\Util\DateTime;
|
|
|
|
use openvk\Web\Models\Repositories\{Users};
|
|
|
|
use Nette\Database\Table\ActiveRow;
|
|
|
|
|
|
|
|
class Ban extends RowModel
|
|
|
|
{
|
|
|
|
protected $tableName = "bans";
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getId(): int
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
|
|
|
return $this->getRecord()->id;
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getReason(): ?string
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
|
|
|
return $this->getRecord()->reason;
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getUser(): ?User
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
2025-01-31 18:20:13 +03:00
|
|
|
return (new Users())->get($this->getRecord()->user);
|
2023-08-11 16:50:19 +03:00
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getInitiator(): ?User
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
2025-01-31 18:20:13 +03:00
|
|
|
return (new Users())->get($this->getRecord()->initiator);
|
2023-08-11 16:50:19 +03:00
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getStartTime(): int
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
|
|
|
return $this->getRecord()->iat;
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getEndTime(): int
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
|
|
|
return $this->getRecord()->exp;
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getTime(): int
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
|
|
|
return $this->getRecord()->time;
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function isPermanent(): bool
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
|
|
|
return $this->getEndTime() === 0;
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function isRemovedManually(): bool
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
|
|
|
return (bool) $this->getRecord()->removed_manually;
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function isOver(): bool
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
|
|
|
return $this->isRemovedManually();
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function whoRemoved(): ?User
|
2023-08-11 16:50:19 +03:00
|
|
|
{
|
2025-01-31 18:20:13 +03:00
|
|
|
return (new Users())->get($this->getRecord()->removed_by);
|
2023-08-11 16:50:19 +03:00
|
|
|
}
|
|
|
|
}
|