Skip to content

Commit

Permalink
Created mutator for requestable attribute
Browse files Browse the repository at this point in the history
Signed-off-by: snipe <[email protected]>
  • Loading branch information
snipe committed Nov 29, 2023
1 parent 189c90e commit 3152df2
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 3152df2

Please sign in to comment.