openvk/Web/Models/Repositories/Managers.php
Alexander Minkin 6ec54a379d
feat: add linting of code (#1220)
* feat(lint): add php-cs-fixer for linting

Removing previous CODE_STYLE as it was not enforced anyway and using PER-CS 2.0.

This is not the reformatting commit.

* style: format code according to PER-CS 2.0 with php-cs-fixer

* ci(actions): add lint action

Resolves #1132.
2025-01-31 18:20:13 +03:00

39 lines
982 B
PHP

<?php
declare(strict_types=1);
namespace openvk\Web\Models\Repositories;
use openvk\Web\Models\Entities\Club;
use openvk\Web\Models\Entities\Manager;
use openvk\Web\Models\Entities\User;
use Nette\Database\Table\ActiveRow;
use Chandler\Database\DatabaseConnection;
class Managers
{
use \Nette\SmartObject;
private $context;
private $managers;
public function __construct()
{
$this->context = DatabaseConnection::i()->getContext();
$this->managers = $this->context->table("group_coadmins");
}
private function toManager(?ActiveRow $ar): ?Manager
{
return is_null($ar) ? null : new Manager($ar);
}
public function get(int $id): ?Manager
{
return $this->toManager($this->managers->where("id", $id)->fetch());
}
public function getByUserAndClub(int $user, int $club): ?Manager
{
return $this->toManager($this->managers->where("user", $user)->where("club", $club)->fetch());
}
}