diff --git a/src/Temporal.php b/src/Temporal.php index c8f6255..502bb5c 100644 --- a/src/Temporal.php +++ b/src/Temporal.php @@ -177,7 +177,7 @@ protected function canUpdate() count($this->getDirty()) == 1, ]); - return $truthChecks->filter()->count() === $truthChecks->count(); + return $truthChecks->filter()->count() === $truthChecks->count() ? null : false; } /** @@ -187,8 +187,12 @@ protected function canUpdate() */ protected function endOrDelete() { + if ($this->enableUpdates) { + return; + } + if ($this->valid_start > Carbon::now()) { - return true; + return; } if ($this->isValid()) { diff --git a/tests/TemporalTest.php b/tests/TemporalTest.php index 8322afe..099d716 100644 --- a/tests/TemporalTest.php +++ b/tests/TemporalTest.php @@ -203,7 +203,10 @@ public function testItCorrectlySetsTheValidEndOfTheCurrentWhenThereIsAScheduling 'valid_end' => null ]); - $this->assertEquals(Carbon::now()->addDays(15)->toDateTimeString(), $currentCommission->fresh()->valid_end); + $this->assertEquals( + Carbon::now()->addDays(15)->toDateString(), + $currentCommission->fresh()->valid_end->toDateString() + ); } /** @@ -310,6 +313,18 @@ public function testItDeletesACommissionCompletelyIfItHasNotStartedYet() $this->assertNull($commission); } + /** + * Tests... + */ + public function testItCanDeleteIfTheUserHasSpecifiedToAllowUpdates() + { + $commission = $this->createCommission(); + $commission->enableUpdates()->delete(); + $commission = $commission->fresh(); + + $this->assertNull($commission); + } + /** * Tests... */