2025-01-31 18:20:13 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-09-17 00:21:29 +03:00
|
|
|
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";
|
2025-01-31 18:20:13 +03:00
|
|
|
|
|
|
|
public function getOwnerId(): int
|
2022-09-17 00:21:29 +03:00
|
|
|
{
|
|
|
|
return $this->getRecord()->owner_id;
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getType(): string
|
2022-09-17 00:21:29 +03:00
|
|
|
{
|
2025-01-31 18:20:13 +03:00
|
|
|
if ($this->getOwnerId() < 0) {
|
2022-09-17 00:21:29 +03:00
|
|
|
return "club";
|
2025-01-31 18:20:13 +03:00
|
|
|
}
|
2022-09-17 00:21:29 +03:00
|
|
|
|
|
|
|
return "user";
|
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getUser(): ?User
|
2022-09-17 00:21:29 +03:00
|
|
|
{
|
2025-01-31 18:20:13 +03:00
|
|
|
return (new Users())->get($this->getOwnerId());
|
2022-09-17 00:21:29 +03:00
|
|
|
}
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
public function getClub(): ?Club
|
2022-09-17 00:21:29 +03:00
|
|
|
{
|
2025-01-31 18:20:13 +03:00
|
|
|
return (new Clubs())->get($this->getOwnerId() * -1);
|
2022-09-17 00:21:29 +03:00
|
|
|
}
|
|
|
|
}
|