Skip to content

Commit

Permalink
Merge pull request #13970 from snipe/bug/sc-24149
Browse files Browse the repository at this point in the history
Created mutator for requestable attribute
  • Loading branch information
snipe authored Nov 29, 2023
2 parents 189c90e + 3152df2 commit 96210e9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/Models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,27 @@ public function getComponentCost(){
return $cost;
}

/**
* -----------------------------------------------
* BEGIN MUTATORS
* -----------------------------------------------
**/

/**
* This sets the requestable to a boolean 0 or 1. This accounts for forms or API calls that
* explicitly pass the requestable field but it has a null or empty value.
*
* This will also correctly parse a 1/0 if "true"/"false" is passed.
*
* @param $value
* @return void
*/
public function setRequestableAttribute($value)
{
$this->attributes['requestable'] = (int) filter_var($value, FILTER_VALIDATE_BOOLEAN);
}


/**
* -----------------------------------------------
* BEGIN QUERY SCOPES
Expand Down

0 comments on commit 96210e9

Please sign in to comment.