2017-07-12 17:51:22 -07:00
|
|
|
<?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)
|
|
|
|
{
|
2017-07-12 19:23:54 -07:00
|
|
|
|
2017-07-12 17:51:22 -07:00
|
|
|
$array = [
|
2017-07-25 23:40:30 -07:00
|
|
|
'name' => e($field->name),
|
|
|
|
'db_column_name' => e($field->db_column_name()),
|
|
|
|
'format' => e($field->format),
|
2017-07-12 19:23:54 -07:00
|
|
|
'required' => $field->pivot->required
|
2017-07-12 17:51:22 -07:00
|
|
|
];
|
|
|
|
return $array;
|
|
|
|
}
|
2017-07-12 19:23:54 -07:00
|
|
|
|
|
|
|
|
2017-07-12 17:51:22 -07:00
|
|
|
}
|