Skip to content

Commit 62c469d

Browse files
authored
Merge pull request #32 from Lomkit/fix/relation-limit
✨ dont apply limits on relationships
2 parents e3367b1 + d3b7132 commit 62c469d

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Http/Controllers/Controller.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ abstract class Controller extends \Illuminate\Routing\Controller
2626
*/
2727
public static $resource;
2828

29-
//@TODO: voir si toutes ces manières de call en static c'est pas plus dérangeant qu'autre chose
30-
//@TODO: surtout avec octane où il faut éviter le static !?
3129
/**
3230
* Get a fresh instance of the resource represented by the entry.
3331
*
@@ -39,6 +37,4 @@ public static function newResource(): Resource
3937

4038
return new $resource;
4139
}
42-
43-
//@TODO: are controllers useless in a certain way ??
4440
}

src/Query/Traits/PerformSearch.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ public function search(array $parameters = []) {
5151
$this->applyAggregates($parameters['aggregates']);
5252
});
5353

54-
// @TODO: is this a problem also with HasMany ??
55-
// @TODO: this will be the problem for every relation, need to fix this
56-
// In case of BelongsToMany we cap the limit
57-
$limit = $this->queryBuilder instanceof \Illuminate\Database\Eloquent\Relations\BelongsToMany ? 9999 : ($parameters['limit'] ?? 50);
58-
$this->queryBuilder->limit($limit);
54+
// In case we are in a relation we don't apply the limits since we dont know how much records will be related.
55+
if (!$this->queryBuilder instanceof Relation) {
56+
$this->queryBuilder->limit($parameters['limit'] ?? 50);
57+
}
5958

6059
return $this->queryBuilder;
6160
}

0 commit comments

Comments
 (0)