Set qty mutators
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
0d29ac9856
commit
2353c8199c
3 changed files with 89 additions and 0 deletions
|
@ -365,6 +365,35 @@ class Accessory extends SnipeModel
|
||||||
$accessory_user->limit(1)->delete();
|
$accessory_user->limit(1)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------
|
||||||
|
* BEGIN MUTATORS
|
||||||
|
* -----------------------------------------------
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This sets a value for qty if no value is given. The database does not allow this
|
||||||
|
* field to be null, and in the other areas of the code, we set a default, but the importer
|
||||||
|
* does not.
|
||||||
|
*
|
||||||
|
* This simply checks that there is a value for quantity, and if there isn't, set it to 0.
|
||||||
|
*
|
||||||
|
* @author A. Gianotto <snipe@snipe.net>
|
||||||
|
* @since v6.3.4
|
||||||
|
* @param $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setQtyAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['qty'] = (!$value) ? 0 : intval($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------
|
||||||
|
* BEGIN QUERY SCOPES
|
||||||
|
* -----------------------------------------------
|
||||||
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query builder scope to order on company
|
* Query builder scope to order on company
|
||||||
*
|
*
|
||||||
|
|
|
@ -224,6 +224,37 @@ class Component extends SnipeModel
|
||||||
return $this->qty - $this->numCheckedOut();
|
return $this->qty - $this->numCheckedOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------
|
||||||
|
* BEGIN MUTATORS
|
||||||
|
* -----------------------------------------------
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This sets a value for qty if no value is given. The database does not allow this
|
||||||
|
* field to be null, and in the other areas of the code, we set a default, but the importer
|
||||||
|
* does not.
|
||||||
|
*
|
||||||
|
* This simply checks that there is a value for quantity, and if there isn't, set it to 0.
|
||||||
|
*
|
||||||
|
* @author A. Gianotto <snipe@snipe.net>
|
||||||
|
* @since v6.3.4
|
||||||
|
* @param $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setQtyAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['qty'] = (!$value) ? 0 : intval($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------
|
||||||
|
* BEGIN QUERY SCOPES
|
||||||
|
* -----------------------------------------------
|
||||||
|
**/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query builder scope to order on company
|
* Query builder scope to order on company
|
||||||
*
|
*
|
||||||
|
|
|
@ -339,6 +339,35 @@ class Consumable extends SnipeModel
|
||||||
return $remaining;
|
return $remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------
|
||||||
|
* BEGIN MUTATORS
|
||||||
|
* -----------------------------------------------
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This sets a value for qty if no value is given. The database does not allow this
|
||||||
|
* field to be null, and in the other areas of the code, we set a default, but the importer
|
||||||
|
* does not.
|
||||||
|
*
|
||||||
|
* This simply checks that there is a value for quantity, and if there isn't, set it to 0.
|
||||||
|
*
|
||||||
|
* @author A. Gianotto <snipe@snipe.net>
|
||||||
|
* @since v6.3.4
|
||||||
|
* @param $value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setQtyAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['qty'] = (!$value) ? 0 : intval($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* -----------------------------------------------
|
||||||
|
* BEGIN QUERY SCOPES
|
||||||
|
* -----------------------------------------------
|
||||||
|
**/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query builder scope to order on company
|
* Query builder scope to order on company
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue