2025-01-31 18:20:13 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-10-11 19:04:43 +03:00
|
|
|
namespace openvk\Web\Models\Repositories;
|
2025-01-31 18:20:13 +03:00
|
|
|
|
2022-10-11 19:04:43 +03:00
|
|
|
use Chandler\Database\DatabaseConnection;
|
|
|
|
use openvk\Web\Models\Entities\Poll;
|
|
|
|
|
|
|
|
class Polls
|
|
|
|
{
|
|
|
|
private $polls;
|
2025-01-31 18:20:13 +03:00
|
|
|
|
|
|
|
public function __construct()
|
2022-10-11 19:04:43 +03:00
|
|
|
{
|
|
|
|
$this->polls = DatabaseConnection::i()->getContext()->table("polls");
|
|
|
|
}
|
2025-01-31 18:20:13 +03:00
|
|
|
|
|
|
|
public function get(int $id): ?Poll
|
2022-10-11 19:04:43 +03:00
|
|
|
{
|
|
|
|
$poll = $this->polls->get($id);
|
2025-01-31 18:20:13 +03:00
|
|
|
if (!$poll) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-10-11 19:04:43 +03:00
|
|
|
return new Poll($poll);
|
|
|
|
}
|
2025-01-31 18:20:13 +03:00
|
|
|
}
|