Added:
- toolbar refactor
This commit is contained in:
@@ -103,23 +103,14 @@ class MangaRepository extends ServiceEntityRepository
|
||||
return $query->getQuery()->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function findAllSorted(string $sort = 'title', string $order = 'asc'): array
|
||||
public function findAllSortedAndFiltered($sort = 'title', $order = 'asc', $status = 'all')
|
||||
{
|
||||
$qb = $this->createQueryBuilder('m');
|
||||
$qb = $this->createQueryBuilder('m')
|
||||
->orderBy('m.' . $sort, $order);
|
||||
|
||||
switch ($sort) {
|
||||
case 'title':
|
||||
$qb->orderBy('m.title', $order);
|
||||
break;
|
||||
case 'publicationYear':
|
||||
$qb->orderBy('m.publicationYear', $order);
|
||||
break;
|
||||
case 'createdAt':
|
||||
$qb->orderBy('m.createdAt', $order);
|
||||
break;
|
||||
// Ajoutez d'autres cas pour les différentes options de tri
|
||||
default:
|
||||
$qb->orderBy('m.title', 'asc');
|
||||
if ($status !== 'all') {
|
||||
$qb->andWhere('m.status = :status')
|
||||
->setParameter('status', $status);
|
||||
}
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
|
||||
Reference in New Issue
Block a user