From d49cc240a88fd3b95b1113324feaeba86c8f5154 Mon Sep 17 00:00:00 2001 From: Andrey Pokidov Date: Fri, 3 Apr 2020 10:48:17 +0700 Subject: [PATCH] +Status methods for content --- src/Models/Content.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Models/Content.php b/src/Models/Content.php index 84022a4..e9a1f82 100644 --- a/src/Models/Content.php +++ b/src/Models/Content.php @@ -29,4 +29,22 @@ class Content extends Model { return $this->status == self::STATUS_PUBLISHED; } + + public function hide() + { + $this->status = self::STATUS_DRAFT; + } + + public function publish() + { + $this->status = self::STATUS_PUBLISHED; + } + + public function getStatusName() + { + if ($this->isPublished()) { + return __('content.status_published'); + } + return __('content.status_draft'); + } }