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";