Skip to content

Commit 9bfb37b

Browse files
committed
Added where parameter to repository->collection
1 parent 839f6c4 commit 9bfb37b

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/Contracts/Repository/Actions/REST.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ interface REST
88
/**
99
* Returns a cursorized collection
1010
*
11-
* @param int $currentPosition
12-
* @param int $pageSize
13-
*
11+
* @param int $currentPosition
12+
* @param int $pageSize
13+
* @param array $where
1414
* @param string|null $with
1515
*
1616
* @return \LaraPackage\Api\Contracts\Resource\Collection
1717
*/
18-
public function collection($currentPosition, $pageSize, $with = null);
18+
public function collection($currentPosition, $pageSize, $where = [], $with = null);
1919

2020
/**
2121
* Deletes records using the specified ids

src/Repository/Repository.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,19 @@ public function __construct(
5050
/**
5151
* @inheritdoc
5252
*/
53-
public function collection($currentPosition, $pageSize, $with = null)
53+
public function collection($currentPosition, $pageSize, $where = [], $with = null)
5454
{
55-
$collection = $this->model->where('id', '>', $currentPosition);
55+
$query = $this->model->where('id', '>', $currentPosition);
56+
57+
foreach ($where as $key => $value) {
58+
$query->where($key, $value);
59+
}
5660

5761
if ($with) {
58-
$collection = $collection->with($with);
62+
$query = $query->with($with);
5963
}
6064

61-
$paginator = $collection->simplePaginate($pageSize);
65+
$paginator = $query->simplePaginate($pageSize);
6266

6367
return $this->cursor($paginator);
6468
}

0 commit comments

Comments
 (0)