Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit c0f15d3

Browse files
committed
Prevent pivot relationships to be included
1 parent ce6b46c commit c0f15d3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Http/Resources/RelationshipsWithIncludes.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace SkoreLabs\JsonApi\Http\Resources;
44

5-
use Illuminate\Database\Eloquent\{Model, Collection};
5+
use Illuminate\Database\Eloquent\{Model, Collection, Relations\Pivot};
66
use Illuminate\Pagination\LengthAwarePaginator;
77
use Illuminate\Support\Arr;
88

@@ -35,10 +35,9 @@ protected function withRelationships()
3535
}
3636

3737
/**
38-
* Undocumented function
38+
* Attach relationships to the resource.
3939
*
4040
* @param \Illuminate\Database\Eloquent\Model $model
41-
* @param bool $collects
4241
* @return void
4342
*/
4443
protected function attachRelations(Model $model)
@@ -55,7 +54,7 @@ protected function attachRelations(Model $model)
5554
}
5655
}
5756

58-
if ($relationObj instanceof Model) {
57+
if ($relationObj instanceof Model && ! $relationObj instanceof Pivot) {
5958
$this->relationships[$relation]['data'] = $this->processModelRelation(
6059
$relationObj
6160
);

0 commit comments

Comments
 (0)