From 06c8d1de44cc4005fdf63d34589f7bb0a10aff56 Mon Sep 17 00:00:00 2001 From: weizong song Date: Fri, 9 Apr 2021 01:04:27 +0800 Subject: [PATCH] up --- app/Models/Paramedic.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/Models/Paramedic.php b/app/Models/Paramedic.php index 9066497..1a9e051 100755 --- a/app/Models/Paramedic.php +++ b/app/Models/Paramedic.php @@ -18,7 +18,8 @@ class Paramedic extends SoftDeletesModel static::addGlobalScope(new AdminProjectScope()); } - public function getStatusNameAttribute() { + public function getStatusNameAttribute() + { $status_name = $this->status; switch ($this->status) { case self::STATUS_ACTIVE: @@ -31,6 +32,23 @@ class Paramedic extends SoftDeletesModel return $status_name; } + public function toggle() + { + switch ($this->status) { + case self::STATUS_ACTIVE: + $this->update([ + "status" => self::STATUS_INACTIVE + ]); + break; + case self::STATUS_INACTIVE: + $this->update([ + "status" => self::STATUS_ACTIVE + ]); + break; + } + return $this; + } + public function getAvatarUrlAttribute() { $protocol = request()->secure() ? "https" : "http";