mirror of
https://github.com/openvk/openvk
synced 2025-04-23 08:33:02 +03:00
Compare commits
2 commits
b23b770634
...
adb1ff4db3
Author | SHA1 | Date | |
---|---|---|---|
|
adb1ff4db3 | ||
|
e4904347c4 |
1 changed files with 11 additions and 11 deletions
|
@ -13,7 +13,7 @@ class Faves
|
|||
private $context;
|
||||
private $likes;
|
||||
|
||||
private function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
$this->context = DatabaseConnection::i()->getContext();
|
||||
$this->likes = $this->context->table("likes");
|
||||
|
@ -22,21 +22,21 @@ class Faves
|
|||
private function fetchLikes(User $user, string $class = 'Post')
|
||||
{
|
||||
$fetch = $this->likes->where([
|
||||
"model" => "openvk\\Web\\Models\\Entities\\".$class,
|
||||
"model" => "openvk\\Web\\Models\\Entities\\" . $class,
|
||||
"origin" => $user->getRealId(),
|
||||
]);
|
||||
|
||||
return $fetch;
|
||||
}
|
||||
|
||||
public function fetchLikesSection(User $user, string $class = 'Post', int $page = 1, ?int $perPage = NULL): \Traversable
|
||||
public function fetchLikesSection(User $user, string $class = 'Post', int $page = 1, ?int $perPage = null): \Traversable
|
||||
{
|
||||
$perPage ??= OPENVK_DEFAULT_PER_PAGE;
|
||||
$fetch = $this->fetchLikes($user, $class)->page($page, $perPage)->order("index DESC");
|
||||
foreach($fetch as $like) {
|
||||
$className = "openvk\\Web\\Models\\Repositories\\".$class."s";
|
||||
$repo = new $className;
|
||||
if(!$repo) {
|
||||
foreach ($fetch as $like) {
|
||||
$className = "openvk\\Web\\Models\\Repositories\\" . $class . "s";
|
||||
$repo = new $className();
|
||||
if (!$repo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue