mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
3cfcc43efa
* Adds basic GET api support for CustomFieldsets Currently there is not support for getting what fields a given fieldset contains from the API. This commit creates a new API Controller for CustomFieldsets as well as Transformers for CustomFields CustomFieldsets. Additionally, the api route has been updated so that a show method can be access from http://myapp/api/v1/fieldsets/{id} * CustomFieldsetsTransformer only returns id and name of model * Added index api method for CustomFieldsets * Removes copy/paste error in CustomFieldsetController (including search) * Added id to CustomFieldsetsTransformers * Adds custom_fieldset_id as a field when storing and updating AssetModels * Removed uncessesary parameter from CustomFieldsetsController.index * Cleaned up CustomFieldset API
31 lines
744 B
PHP
31 lines
744 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' => $field->name,
|
|
'db_column_name' => $field->db_column_name(),
|
|
'format' => $field->format
|
|
];
|
|
return $array;
|
|
}
|
|
}
|