Skip to content

Commit 003fbb5

Browse files
cs fixwq
1 parent a4ab06a commit 003fbb5

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

src/Eloquent/Model.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ public function refresh()
775775
/**
776776
* Get a serialized attribute from the model.
777777
*
778-
* @param string $key
778+
* @param string $key
779+
*
779780
* @return mixed
780781
*/
781782
public function getSerializedAttribute($key)
@@ -807,7 +808,8 @@ public function getSerializedKey()
807808
/**
808809
* Determine if two models have the same ID and belong to the same table.
809810
*
810-
* @param \Illuminate\Database\Eloquent\Model|null $model
811+
* @param \Illuminate\Database\Eloquent\Model|null $model
812+
*
811813
* @return bool
812814
*/
813815
public function is($model)

src/Relations/BelongsToMany.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
use BackedEnum;
88
use Illuminate\Database\Eloquent\Builder;
99
use Illuminate\Database\Eloquent\Collection;
10-
use Illuminate\Support\Collection as BaseCollection;
1110
use Illuminate\Database\Eloquent\Model;
1211
use Illuminate\Database\Eloquent\Relations\BelongsToMany as EloquentBelongsToMany;
1312
use Illuminate\Support\Arr;
13+
use Illuminate\Support\Collection as BaseCollection;
1414
use MongoDB\BSON\Binary;
1515
use MongoDB\BSON\ObjectId;
1616

1717
use function array_diff;
18+
use function array_intersect;
1819
use function array_map;
20+
use function array_merge;
1921
use function array_values;
2022
use function assert;
23+
use function collect;
2124
use function count;
2225
use function in_array;
2326
use function is_numeric;
@@ -112,7 +115,8 @@ public function create(array $attributes = [], array $joining = [], $touch = tru
112115
/**
113116
* Format the sync / toggle record list so that it is keyed by ID.
114117
*
115-
* @param array $records
118+
* @param array $records
119+
*
116120
* @return array
117121
*/
118122
protected function formatRecordsList($records): array
@@ -133,8 +137,9 @@ protected function formatRecordsList($records): array
133137
*
134138
* Each existing model is detached, and non existing ones are attached.
135139
*
136-
* @param mixed $ids
140+
* @param mixed $ids
137141
* @param bool $touch
142+
*
138143
* @return array
139144
*/
140145
public function toggle($ids, $touch = true)
@@ -193,22 +198,23 @@ public function toggle($ids, $touch = true)
193198
// Once we have finished attaching or detaching the records, we will see if we
194199
// have done any attaching or detaching, and if we have we will touch these
195200
// relationships if they are configured to touch on any database updates.
196-
if ($touch && (count($changes['attached']) ||
197-
count($changes['detached']))) {
198-
201+
if (
202+
$touch && (count($changes['attached']) ||
203+
count($changes['detached']))
204+
) {
199205
$this->parent->touch();
200206
$this->newRelatedQuery()->whereIn($this->relatedKey, $ids)->touch();
201207
}
202208

203209
return $changes;
204210
}
205211

206-
207212
/**
208213
* Sync the intermediate tables with a list of IDs or collection of models.
209214
*
210-
* @param \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|array $ids
211-
* @param bool $detaching
215+
* @param \Illuminate\Support\Collection|Model|array $ids
216+
* @param bool $detaching
217+
*
212218
* @return array
213219
*/
214220
public function sync($ids, $detaching = true)
@@ -259,7 +265,7 @@ public function sync($ids, $detaching = true)
259265
// ton of touch operations until we are totally done syncing the records.
260266
foreach ($records as $id) {
261267
// Only non strict check if exist no update s possible beacause no attributtes
262-
if (!in_array($id, $current)) {
268+
if (! in_array($id, $current)) {
263269
$this->attach($id, [], false);
264270
$changes['attached'][] = $this->castKey($id);
265271
}
@@ -388,7 +394,6 @@ protected function buildDictionary(Collection $results)
388394

389395
foreach ($results as $result) {
390396
foreach ($result->$foreign as $item) {
391-
392397
//Prevent if id is non keyable
393398
if ($item instanceof ObjectId) {
394399
$item = (string) $item;

tests/RelationsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,6 @@ public function testBelongsToManyOid(): void
13381338
$this->assertCount(2, $explorer->planetsVisited);
13391339
$this->assertCount(2, $planet->visitors);
13401340

1341-
13421341
// Detach planets from explorer
13431342
$explorer->planetsVisited()->sync([]);
13441343

0 commit comments

Comments
 (0)