openvk/Web/Models/Entities/Alias.php
n1rwana 5b3a1f50e9
Shortcode aliases (#690)
* Shortcode aliases

* Fixes

* Newline

* Fixes + SQLs renamed

* Fixed clubs aliases
2022-09-17 00:21:29 +03:00

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);
}
}