Skip to content

Commit 7f108dd

Browse files
authored
feat: allow including relationships by default (#96)
* feat: default include * Run Prettier * chore: unnecessary import --------- Co-authored-by: SychO9 <[email protected]>
1 parent a77e526 commit 7f108dd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Endpoint/Concerns/IncludesData.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@
88

99
trait IncludesData
1010
{
11+
protected ?array $defaultInclude = null;
12+
13+
public function defaultInclude(array $include): static
14+
{
15+
$this->defaultInclude = $include;
16+
17+
return $this;
18+
}
19+
1120
private function getInclude(Context $context): array
1221
{
13-
if ($includeString = $context->request->getQueryParams()['include'] ?? null) {
22+
if (
23+
$includeString = $context->request->getQueryParams()['include'] ?? $this->defaultInclude
24+
) {
1425
$include = $this->parseInclude($includeString);
1526

1627
$this->validateInclude(

0 commit comments

Comments
 (0)