From 330a19041d2019538b6a0aad014e4f6aaaa7c14d Mon Sep 17 00:00:00 2001 From: Dipesh Khanal <63183800+Dipesh79@users.noreply.github.com> Date: Sun, 4 Feb 2024 12:52:18 +0545 Subject: [PATCH] feat: added setActive And setInactive function to CanBeInactive Trait (#14) --- src/Traits/CanBeInactive.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Traits/CanBeInactive.php b/src/Traits/CanBeInactive.php index 6ff4f84..88fa36a 100644 --- a/src/Traits/CanBeInactive.php +++ b/src/Traits/CanBeInactive.php @@ -50,4 +50,29 @@ public function getQualifiedInactiveAtColumn(): string return $this->qualifyColumn($this->getInactiveAtColumn()); } + /** + * Inactivate the model. + * + * @return bool + */ + public function setInactive(): bool + { + $this->{$this->getInactiveAtColumn()} = $this->freshTimestamp(); + return $this->save(); + } + + /** + * Activate the model. + * + * @return bool + */ + + public function setActive(): bool + { + $this->{$this->getInactiveAtColumn()} = null; + return $this->save(); + } + + + }