mirror of
https://github.com/openvk/openvk
synced 2024-11-11 09:29:29 +03:00
35 lines
833 B
PHP
35 lines
833 B
PHP
<?php declare(strict_types=1);
|
|
namespace openvk\Web\Models\Repositories;
|
|
use openvk\Web\Models\Entities\Photo;
|
|
use Chandler\Database\DatabaseConnection;
|
|
|
|
class Photos
|
|
{
|
|
private $context;
|
|
private $photos;
|
|
|
|
function __construct()
|
|
{
|
|
$this->context = DatabaseConnection::i()->getContext();
|
|
$this->photos = $this->context->table("photos");
|
|
}
|
|
|
|
function get(int $id): ?Photo
|
|
{
|
|
$photo = $this->photos->get($id);
|
|
if(!$photo) return NULL;
|
|
|
|
return new Photo($photo);
|
|
}
|
|
|
|
function getByOwnerAndVID(int $owner, int $vId): ?Photo
|
|
{
|
|
$photo = $this->photos->where([
|
|
"owner" => $owner,
|
|
"virtual_id" => $vId,
|
|
])->fetch();
|
|
if(!$photo) return NULL;
|
|
|
|
return new Photo($photo);
|
|
}
|
|
}
|