Take page size into account. [skip ci]

This commit is contained in:
James Cole
2016-04-21 10:34:16 +02:00
parent ef48a79d0c
commit 0ef5eeeb55
12 changed files with 23 additions and 28 deletions

View File

@@ -123,28 +123,23 @@ class JournalRepository implements JournalRepositoryInterface
/**
* @param array $types
* @param int $offset
* @param int $page
*
* @param int $pagesize
* @param int $pageSize
*
* @return LengthAwarePaginator
*/
public function getJournalsOfTypes(array $types, int $offset, int $page, int $pagesize = 50): LengthAwarePaginator
public function getJournalsOfTypes(array $types, int $page, int $pageSize = 50): LengthAwarePaginator
{
$set = $this->user
$offset = ($page - 1) * $pageSize;
$query = $this->user
->transactionJournals()
->expanded()
->transactionTypes($types)
->take($pagesize)
->offset($offset)
->orderBy('date', 'DESC')
->orderBy('order', 'ASC')
->orderBy('id', 'DESC')
->get(TransactionJournal::QUERYFIELDS);
->transactionTypes($types);
$count = $this->user->transactionJournals()->transactionTypes($types)->count();
$journals = new LengthAwarePaginator($set, $count, $pagesize, $page);
$count = $query->count();
$set = $query->take($pageSize)->offset($offset)->get(TransactionJournal::QUERYFIELDS);
$journals = new LengthAwarePaginator($set, $count, $pageSize, $page);
return $journals;
}

View File

@@ -57,12 +57,12 @@ interface JournalRepositoryInterface
/**
* @param array $types
* @param int $offset
* @param int $page
* @param int $pageSize
*
* @return LengthAwarePaginator
*/
public function getJournalsOfTypes(array $types, int $offset, int $page): LengthAwarePaginator;
public function getJournalsOfTypes(array $types, int $page, int $pageSize = 50): LengthAwarePaginator;
/**
* @param string $type