mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 22:19:41 -08:00
922d6937ae
* There is no notes field on accessories. Fixes Importer Test. * Fix notification test. We should see a checkout not allowed exception when trying to check out to a location if the asset requires acceptance. * Fix Custom field import. Add a test for custom field import, and fix a few issues related to importing custom fields. This will restore v3 functionality. * Add UI support for mapping custom fields. This still requires the field mappings to be created/assigned in advance, but will fetch all custom field names and allow them to be selected when setting up custom field mappings. This commit also updates laravel-mix to v1.4.3 and other node dependencies to fix some build issues. * Fix some requestable asset page/assetloc issues. I'd love to know why laravel expections relationships to be in lower case... but thats a question for another day.
37 lines
1,019 B
PHP
37 lines
1,019 B
PHP
<?php
|
|
namespace App\Http\Transformers;
|
|
|
|
use App\Models\CustomField;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use App\Helpers\Helper;
|
|
use Gate;
|
|
|
|
class CustomFieldsTransformer
|
|
{
|
|
|
|
public function transformCustomFields (Collection $fields, $total)
|
|
{
|
|
$array = array();
|
|
foreach ($fields as $field) {
|
|
$array[] = self::transformCustomField($field);
|
|
}
|
|
return (new DatatablesTransformer)->transformDatatables($array, $total);
|
|
}
|
|
|
|
public function transformCustomField (CustomField $field)
|
|
{
|
|
|
|
$array = [
|
|
'name' => e($field->name),
|
|
'db_column_name' => e($field->db_column_name()),
|
|
'format' => e($field->format),
|
|
'required' => $field->pivot ? $field->pivot->required : false,
|
|
'created_at' => Helper::getFormattedDateObject($field->created_at, 'datetime'),
|
|
'updated_at' => Helper::getFormattedDateObject($field->updated_at, 'datetime'),
|
|
];
|
|
return $array;
|
|
}
|
|
|
|
|
|
}
|