mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -08:00
Merge pull request #12315 from snipe/features/added_default_values_to_model_api
Features/added default values to model api
This commit is contained in:
commit
bd3f730cb2
|
@ -22,6 +22,22 @@ class AssetModelsTransformer
|
|||
|
||||
public function transformAssetModel(AssetModel $assetmodel)
|
||||
{
|
||||
|
||||
$default_field_values = array();
|
||||
|
||||
// Reach into the custom fields and models_custom_fields pivot table to find the default values for this model
|
||||
if ($assetmodel->fieldset) {
|
||||
foreach($assetmodel->fieldset->fields AS $field) {
|
||||
$default_field_values[] = [
|
||||
'name' => e($field->name),
|
||||
'db_column_name' => e($field->db_column_name()),
|
||||
'default_value' => ($field->defaultValue($assetmodel->id)) ? e($field->defaultValue($assetmodel->id)) : null,
|
||||
'format' => e($field->format),
|
||||
'required' => ($field->pivot->required == '1') ? true : false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$array = [
|
||||
'id' => (int) $assetmodel->id,
|
||||
'name' => e($assetmodel->name),
|
||||
|
@ -44,6 +60,7 @@ class AssetModelsTransformer
|
|||
'id' => (int) $assetmodel->fieldset->id,
|
||||
'name'=> e($assetmodel->fieldset->name),
|
||||
] : null,
|
||||
'default_fieldset_values' => $default_field_values,
|
||||
'eol' => ($assetmodel->eol > 0) ? $assetmodel->eol.' months' : 'None',
|
||||
'requestable' => ($assetmodel->requestable == '1') ? true : false,
|
||||
'notes' => e($assetmodel->notes),
|
||||
|
|
Loading…
Reference in a new issue