Added support for ordering in shortcode:list command

This commit is contained in:
Alejandro Celaya
2016-10-22 23:10:30 +02:00
parent 85146e5676
commit 9ac48bfbc5
4 changed files with 36 additions and 12 deletions

View File

@@ -43,7 +43,11 @@ class ShortUrlRepository extends EntityRepository implements ShortUrlRepositoryI
$fieldName = is_array($orderBy) ? key($orderBy) : $orderBy;
$order = is_array($orderBy) ? $orderBy[$fieldName] : 'ASC';
if ($fieldName === 'visits') {
if (in_array($fieldName, [
'visits',
'visitsCount',
'visitCount',
])) {
$qb->addSelect('COUNT(v) AS totalVisits')
->leftJoin('s.visits', 'v')
->groupBy('s')