Skip to content

Commit

Permalink
Add guard clauses around some License and LicenseSeat models functions
Browse files Browse the repository at this point in the history
  • Loading branch information
inietov committed Sep 6, 2023
1 parent e920199 commit 1509c51
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
27 changes: 18 additions & 9 deletions app/Models/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ public function manufacturer()
*/
public function checkin_email()
{
return $this->category->checkin_email;
if ($this->category) {
return $this->category->checkin_email;
}
return false;
}

/**
Expand All @@ -335,7 +338,11 @@ public function checkin_email()
*/
public function requireAcceptance()
{
return $this->category->require_acceptance;
if ($this->category) {
return $this->category->require_acceptance;
}

return false;
}

/**
Expand All @@ -348,14 +355,16 @@ public function requireAcceptance()
*/
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;

}

/**
Expand Down
5 changes: 4 additions & 1 deletion app/Models/LicenseSeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public function getCompanyableParents()
*/
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()
Expand Down

0 comments on commit 1509c51

Please sign in to comment.