Skip to content

Commit fb2d848

Browse files
author
pilo
committed
run cs:fix for modified files
1 parent 0518aaa commit fb2d848

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Relations/BelongsToMany.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Database\Eloquent\Model;
1010
use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany;
1111
use Illuminate\Support\Arr;
12+
use MongoDB\BSON\ObjectId;
1213
use MongoDB\Laravel\Eloquent\Model as DocumentModel;
1314

1415
use function array_diff;
@@ -20,6 +21,7 @@
2021
use function count;
2122
use function in_array;
2223
use function is_numeric;
24+
use function is_object;
2325

2426
/**
2527
* @template TRelatedModel of Model
@@ -208,11 +210,12 @@ public function attach($id, array $attributes = [], $touch = true)
208210

209211
// Attach the new ids to the parent model.
210212
if (\MongoDB\Laravel\Eloquent\Model::isDocumentModel($this->parent)) {
211-
if ($id instanceof \MongoDB\BSON\ObjectId) {
213+
if ($id instanceof ObjectId) {
212214
$id = [$id];
213215
} else {
214216
$id = (array) $id;
215217
}
218+
216219
$this->parent->push($this->relatedPivotKey, $id, true);
217220
} else {
218221
$instance = new $this->related();

tests/RelationsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public function testBelongsToManyRelationSupportsArrayForeignKeys(): void
350350
$this->assertCount(2, $retrievedUser->roles);
351351
$this->assertEqualsCanonicalizing(
352352
[$role1->id, $role2->id],
353-
$retrievedUser->roles->pluck('id')->toArray()
353+
$retrievedUser->roles->pluck('id')->toArray(),
354354
);
355355
}
356356

0 commit comments

Comments
 (0)