From 412d15447be91436ef9b48f0b902635c8398f8f0 Mon Sep 17 00:00:00 2001 From: Norlihazmey Ghazali Date: Tue, 31 Mar 2020 09:47:28 +0800 Subject: [PATCH] adding activate and revoke method directly to model apiKey --- src/ApiKey.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/ApiKey.php b/src/ApiKey.php index 7923ee9..7f8eb26 100644 --- a/src/ApiKey.php +++ b/src/ApiKey.php @@ -88,4 +88,32 @@ public function isActive() { return true === $this->status; } + + /** + * Activate the current key. + * + * @return $this + */ + public function activate() + { + $this->update([ + 'status' => true, + ]); + + return $this; + } + + /** + * Revoke the current key. + * + * @return $this + */ + public function revoke() + { + $this->update([ + 'status' => false, + ]); + + return $this; + } }