From 1509c512a5cfed0a3dd8424f431e1615398677ec Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 6 Sep 2023 11:54:11 -0600 Subject: [PATCH] Add guard clauses around some License and LicenseSeat models functions --- app/Models/License.php | 27 ++++++++++++++++++--------- app/Models/LicenseSeat.php | 5 ++++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/Models/License.php b/app/Models/License.php index 162b3d662a..44f1f45b70 100755 --- a/app/Models/License.php +++ b/app/Models/License.php @@ -323,7 +323,10 @@ class License extends Depreciable */ public function checkin_email() { - return $this->category->checkin_email; + if ($this->category) { + return $this->category->checkin_email; + } + return false; } /** @@ -335,7 +338,11 @@ class License extends Depreciable */ public function requireAcceptance() { - return $this->category->require_acceptance; + if ($this->category) { + return $this->category->require_acceptance; + } + + return false; } /** @@ -348,14 +355,16 @@ class License extends Depreciable */ public function getEula() { - - if ($this->category->eula_text) { - return Helper::parseEscapedMarkedown($this->category->eula_text); - } elseif ($this->category->use_default_eula == '1') { - return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text); - } else { - return false; + if ($this->category){ + if ($this->category->eula_text) { + return Helper::parseEscapedMarkedown($this->category->eula_text); + } elseif ($this->category->use_default_eula == '1') { + return Helper::parseEscapedMarkedown(Setting::getSettings()->default_eula_text); + } } + + return false; + } /** diff --git a/app/Models/LicenseSeat.php b/app/Models/LicenseSeat.php index d2a99d3c56..8a51c0c9cf 100755 --- a/app/Models/LicenseSeat.php +++ b/app/Models/LicenseSeat.php @@ -48,7 +48,10 @@ class LicenseSeat extends SnipeModel implements ICompanyableChild */ public function requireAcceptance() { - return $this->license->category->require_acceptance; + if ($this->license && $this->license->category) { + return $this->license->category->require_acceptance; + } + return false; } public function getEula()