Skip to content

Commit 6cc63c6

Browse files
committed
More Codacy fixes
1 parent c531c9b commit 6cc63c6

3 files changed

Lines changed: 6 additions & 12 deletions

File tree

src/Observers/HasManyObserver.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ public function updating(Model $model, $attribute, $value)
1616
$childModels = $model->{$attribute}()->get()->all();
1717

1818
for ($i = 0; $i < $count; $i++) {
19-
if ($i < count($childModels)) {
20-
$childModels[$i]->update($value[$i]);
21-
} else {
22-
$model->{$attribute}()->create($value[$i]);
23-
}
19+
$i < count($childModels)
20+
? $childModels[$i]->update($value[$i])
21+
: $model->{$attribute}()->create($value[$i]);
2422
}
2523

2624
if ($count < count($childModels)) {

src/Observers/HasOneObserver.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ public function updating(Model $model, $attribute, $value)
1414
$childModel = $model->{$attribute}()->first();
1515

1616
if (! empty($childModel)) {
17-
if (count($value)) {
18-
$childModel->update($value[0]);
19-
} else {
20-
$childModel->delete();
21-
}
17+
count($value)
18+
? $childModel->update($value[0])
19+
: $childModel->delete();
2220
} elseif (count($value)) {
2321
$model->{$attribute}()->create($value[0]);
2422
}

tests/Unit/MorphOneTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ public function testFillAttributeForDelete()
110110
$newEmployee = Employee::create(['name' => 'Test']);
111111
$newEmployee->summary()->save(Summary::make(['text' => 'summary text']));
112112

113-
$id = $newEmployee->fresh()->summary->id;
114-
115113
$updateRequest = [
116114
'name' => 'Test 2',
117115
'summary' => [

0 commit comments

Comments
 (0)