mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
implement torrent bookmarks feature
This commit is contained in:
parent
a8b08bed06
commit
3d74818303
5 changed files with 277 additions and 36 deletions
40
src/Repository/TorrentBookmarkRepository.php
Normal file
40
src/Repository/TorrentBookmarkRepository.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\TorrentBookmark;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<TorrentBookmark>
|
||||
*
|
||||
* @method TorrentBookmark|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method TorrentBookmark|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method TorrentBookmark[] findAll()
|
||||
* @method TorrentBookmark[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class TorrentBookmarkRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, TorrentBookmark::class);
|
||||
}
|
||||
|
||||
public function findUserLastTorrentBookmark(
|
||||
int $torrentId,
|
||||
int $userId
|
||||
): ?TorrentBookmark
|
||||
{
|
||||
return $this->createQueryBuilder('tb')
|
||||
->where('tb.torrentId = :torrentId')
|
||||
->andWhere('tb.userId = :userId')
|
||||
->setParameter('torrentId', $torrentId)
|
||||
->setParameter('userId', $userId)
|
||||
->orderBy('tb.id', 'DESC') // same to ts.added
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue