mirror of
https://github.com/openvk/openvk
synced 2024-11-16 12:09:14 +03:00
5b3a1f50e9
* Shortcode aliases * Fixes * Newline * Fixes + SQLs renamed * Fixed clubs aliases
34 lines
694 B
PHP
34 lines
694 B
PHP
<?php declare(strict_types=1);
|
|
namespace openvk\Web\Models\Entities;
|
|
|
|
use openvk\Web\Models\RowModel;
|
|
use openvk\Web\Models\Entities\{User, Club};
|
|
use openvk\Web\Models\Repositories\{Users, Clubs};
|
|
|
|
class Alias extends RowModel
|
|
{
|
|
protected $tableName = "aliases";
|
|
|
|
function getOwnerId(): int
|
|
{
|
|
return $this->getRecord()->owner_id;
|
|
}
|
|
|
|
function getType(): string
|
|
{
|
|
if ($this->getOwnerId() < 0)
|
|
return "club";
|
|
|
|
return "user";
|
|
}
|
|
|
|
function getUser(): ?User
|
|
{
|
|
return (new Users)->get($this->getOwnerId());
|
|
}
|
|
|
|
function getClub(): ?Club
|
|
{
|
|
return (new Clubs)->get($this->getOwnerId() * -1);
|
|
}
|
|
}
|