Fixes #3774 - fixes for inconsistent API responses (‘’ vs null) and adds escaping

This commit is contained in:
snipe 2017-07-25 23:40:30 -07:00
parent 59006964d1
commit 847262e989
17 changed files with 65 additions and 65 deletions

View file

@ -23,17 +23,17 @@ class AccessoriesTransformer
$array = [
'id' => $accessory->id,
'name' => e($accessory->name),
'company' => ($accessory->company) ? ['id' => $accessory->company->id,'name'=> e($accessory->company->name)] : '',
'manufacturer' => ($accessory->manufacturer) ? ['id' => $accessory->manufacturer->id,'name'=> e($accessory->manufacturer->name)] : '',
'company' => ($accessory->company) ? ['id' => $accessory->company->id,'name'=> e($accessory->company->name)] : null,
'manufacturer' => ($accessory->manufacturer) ? ['id' => $accessory->manufacturer->id,'name'=> e($accessory->manufacturer->name)] : null,
'model_number' => ($accessory->model_number) ? e($accessory->model_number) : null,
'category' => ($accessory->category) ? ['id' => $accessory->category->id,'name'=> e($accessory->category->name)] : '',
'location' => ($accessory->location) ? ['id' => $accessory->location->id,'name'=> e($accessory->location->name)] : '',
'category' => ($accessory->category) ? ['id' => $accessory->category->id,'name'=> e($accessory->category->name)] : null,
'location' => ($accessory->location) ? ['id' => $accessory->location->id,'name'=> e($accessory->location->name)] : null,
'notes' => ($accessory->notes) ? e($accessory->notes) : null,
'qty' => ($accessory->qty) ? e($accessory->qty) : null,
'qty' => ($accessory->qty) ? (int) $accessory->qty : null,
'purchase_date' => ($accessory->purchase_date) ? Helper::getFormattedDateObject($accessory->purchase_date, 'date') : null,
'purchase_cost' => ($accessory->purchase_cost) ? e($accessory->purchase_cost) : null,
'order_number' => ($accessory->order_number) ? e($accessory->order_number) : null,
'min_qty' => ($accessory->min_amt) ? e($accessory->min_amt) : null,
'min_qty' => ($accessory->min_amt) ? (int) $accessory->min_amt : null,
'remaining_qty' => $accessory->numRemaining(),
'created_at' => Helper::getFormattedDateObject($accessory->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($accessory->updated_at, 'datetime'),

View file

@ -21,10 +21,10 @@ class AssetModelsTransformer
{
$array = [
'id' => $assetmodel->id,
'id' => (int) $assetmodel->id,
'name' => e($assetmodel->name),
'manufacturer' => ($assetmodel->manufacturer_id) ? $assetmodel->manufacturer : null,
'image' => ($assetmodel->image!='') ? url('/').'/uploads/models/'.e($assetmodel->image) : '',
'image' => ($assetmodel->image!='') ? url('/').'/uploads/models/'.e($assetmodel->image) : null,
'model_number' => e($assetmodel->model_number),
'depreciation' => ($assetmodel->depreciation) ? $assetmodel->depreciation : 'No',
'assets_count' => $assetmodel->assets_count,

View file

@ -27,12 +27,12 @@ class CompaniesTransformer
'name' => e($company->name),
"created_at" => Helper::getFormattedDateObject($company->created_at, 'datetime'),
"updated_at" => Helper::getFormattedDateObject($company->updated_at, 'datetime'),
"assets_count" => $company->assets_count,
"licenses_count" => $company->licenses_count,
"accessories_count" => $company->accessories_count,
"consumables_count" => $company->consumables_count,
"components_count" => $company->components_count,
"users_count" => $company->users_count
"assets_count" => (int) $company->assets_count,
"licenses_count" => (int) $company->licenses_count,
"accessories_count" => (int) $company->accessories_count,
"consumables_count" => (int) $company->consumables_count,
"components_count" => (int) $company->components_count,
"users_count" => (int) $company->users_count
];
$permissions_array['available_actions'] = [

View file

@ -27,8 +27,8 @@ class ComponentsTransformer
'id' => (int) $component->location->id,
'name' => e($component->location->name)
] : null,
'qty' => number_format($component->qty),
'min_amt' => e($component->min_amt),
'qty' => ($component->qty!='') ? (int) $component->qty : null,
'min_amt' => ($component->min_amt!='') ? (int) $component->min_amt : null,
'category' => ($component->category) ? [
'id' => (int) $component->category->id,
'name' => e($component->category->name)

View file

@ -21,20 +21,20 @@ class ConsumablesTransformer
public function transformConsumable (Consumable $consumable)
{
$array = [
'category' => ($consumable->category) ? ['id' => $consumable->category->id, 'name' => $consumable->category->name] : null,
'company' => ($consumable->company) ? ['id' => $consumable->company->id, 'name' => $consumable->company->name] : null,
'id' => $consumable->id,
'item_no' => $consumable->item_no,
'location' => ($consumable->location) ? ['id' => $consumable->location->id, 'name' => $consumable->location->name] : null,
'manufacturer' => ($consumable->manufacturer) ? ['id' => $consumable->manufacturer->id, 'name' => $consumable->manufacturer->name] : null,
'min_amt' => $consumable->min_amt,
'model_number' => $consumable->model_number,
'name' => $consumable->name,
'id' => (int) $consumable->id,
'category' => ($consumable->category) ? ['id' => $consumable->category->id, 'name' => e($consumable->category->name)] : null,
'company' => ($consumable->company) ? ['id' => (int) $consumable->company->id, 'name' => e($consumable->company->name)] : null,
'item_no' => e($consumable->item_no),
'location' => ($consumable->location) ? ['id' => (int) $consumable->location->id, 'name' => e($consumable->location->name)] : null,
'manufacturer' => ($consumable->manufacturer) ? ['id' => (int) $consumable->manufacturer->id, 'name' => e($consumable->manufacturer->name)] : null,
'min_amt' => (int) $consumable->min_amt,
'model_number' => e($consumable->model_number),
'name' => e($consumable->name),
'remaining' => $consumable->numRemaining(),
'order_number' => $consumable->order_number,
'order_number' => e($consumable->order_number),
'purchase_cost' => Helper::formatCurrencyOutput($consumable->purchase_cost),
'purchase_date' => Helper::getFormattedDateObject($consumable->purchase_date, 'date'),
'qty' => $consumable->qty,
'qty' => (int) $consumable->qty,
'created_at' => Helper::getFormattedDateObject($consumable->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($consumable->updated_at, 'datetime'),
];

View file

@ -22,9 +22,9 @@ class CustomFieldsTransformer
{
$array = [
'name' => $field->name,
'db_column_name' => $field->db_column_name(),
'format' => $field->format,
'name' => e($field->name),
'db_column_name' => e($field->db_column_name()),
'format' => e($field->format),
'required' => $field->pivot->required
];
return $array;

View file

@ -35,7 +35,7 @@ class CustomFieldsetsTransformer
}
$array = [
'id' => $fieldset->id,
'id' => (int) $fieldset->id,
'name' => e($fieldset->name),
'fields' => (new CustomFieldsTransformer)->transformCustomFields($fields, $fieldset->fields_count),
'models' => (new DatatablesTransformer)->transformDatatables($modelsArray, $fieldset->models_count)

View file

@ -23,7 +23,7 @@ class DepartmentsTransformer
if ($department) {
$array = [
'id' => e($department->id),
'id' => (int) $department->id,
'name' => e($department->name),
'company' => ($department->company) ? [
'id' => (int) $department->company->id,

View file

@ -21,7 +21,7 @@ class DepreciationsTransformer
public function transformDepreciation (Depreciation $depreciation)
{
$array = [
'id' => e($depreciation->id),
'id' => (int) $depreciation->id,
'name' => e($depreciation->name),
'months' => $depreciation->months . ' '. trans('general.months'),
'created_at' => Helper::getFormattedDateObject($depreciation->created_at, 'datetime'),

View file

@ -21,10 +21,10 @@ class GroupsTransformer
public function transformGroup (Group $group)
{
$array = [
'id' => e($group->id),
'id' => (int) $group->id,
'name' => e($group->name),
'permissions' => $group->permissions,
'users_count' => $group->users_count,
'users_count' => (int) $group->users_count,
'created_at' => Helper::getFormattedDateObject($group->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($group->updated_at, 'datetime'),
];

View file

@ -20,11 +20,11 @@ class ImportsTransformer
public function transformImport(Import $import)
{
$array = [
'id' => $import->id,
'file_path' => $import->file_path,
'id' => (int) $import->id,
'file_path' => e($import->file_path),
'filesize' => Setting::fileSizeConvert($import->filesize),
'name' => $import->name,
'import_type' => $import->import_type,
'name' => e($import->name),
'import_type' => e($import->import_type),
'created_at' => $import->created_at->diffForHumans(),
'header_row' => $import->header_row,
'first_row' => $import->first_row,

View file

@ -21,25 +21,25 @@ class LicensesTransformer
public function transformLicense (License $license)
{
$array = [
'id' => $license->id,
'id' => (int) $license->id,
'name' => e($license->name),
'company' => ($license->company) ? ['id' => $license->company->id,'name'=> e($license->company->name)] : null,
'manufacturer' => ($license->manufacturer) ? ['id' => $license->manufacturer->id,'name'=> e($license->manufacturer->name)] : null,
'company' => ($license->company) ? ['id' => (int) $license->company->id,'name'=> e($license->company->name)] : null,
'manufacturer' => ($license->manufacturer) ? ['id' => (int) $license->manufacturer->id,'name'=> e($license->manufacturer->name)] : null,
'product_key' => e($license->serial),
'order_number' => e($license->order_number),
'purchase_order' => e($license->purchase_order),
'purchase_date' => Helper::getFormattedDateObject($license->purchase_date, 'date'),
'purchase_cost' => e($license->purchase_cost),
'depreciation' => ($license->depreciation) ? ['id' => $license->depreciation->id,'name'=> e($license->depreciation->name)] : null,
'depreciation' => ($license->depreciation) ? ['id' => (int) $license->depreciation->id,'name'=> e($license->depreciation->name)] : null,
'notes' => e($license->notes),
'expiration_date' => Helper::getFormattedDateObject($license->expiration_date, 'date'),
'total_seats' => e($license->seats),
'total_seats' => (int) $license->total_seats,
'remaining_qty' => $license->remaincount(),
'min_qty' => $license->remaincount(),
'license_name' => e($license->license_name),
'license_email' => e($license->license_email),
'maintained' => ($license->maintained == 1) ? true : false,
'supplier' => ($license->supplier) ? ['id' => $license->supplier->id,'name'=> e($license->supplier->name)] : null,
'supplier' => ($license->supplier) ? ['id' => (int) $license->supplier->id,'name'=> e($license->supplier->name)] : null,
'created_at' => Helper::getFormattedDateObject($license->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($license->updated_at, 'datetime'),
'user_can_checkout' => (bool) ($license->remaincount() > 0),

View file

@ -33,7 +33,7 @@ class LocationsTransformer
}
$array = [
'id' => e($location->id),
'id' => (int) $location->id,
'name' => e($location->name),
'address' => e($location->address),
'city' => e($location->city),
@ -44,7 +44,7 @@ class LocationsTransformer
'assets' => $assets_arr,
'created_at' => Helper::getFormattedDateObject($location->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($location->updated_at, 'datetime'),
'parent_id' => e($location->parent_id),
'parent_id' => ($location->parent_id) ? (int) $location->parent_id : null,
'children' => $children_arr,
];

View file

@ -23,16 +23,16 @@ class ManufacturersTransformer
if ($manufacturer) {
$array = [
'id' => e($manufacturer->id),
'id' => (int) $manufacturer->id,
'name' => e($manufacturer->name),
'url' => e($manufacturer->url),
'support_url' => e($manufacturer->support_url),
'support_phone' => e($manufacturer->support_phone),
'support_email' => e($manufacturer->support_email),
'assets_count' => e($manufacturer->assets_count),
'licenses_count' => e($manufacturer->licenses_count),
'consumables_count' => e($manufacturer->consumables_count),
'accessories_count' => e($manufacturer->accessories_count),
'assets_count' => (int) $manufacturer->assets_count,
'licenses_count' => (int) $manufacturer->licenses_count,
'consumables_count' => (int) $manufacturer->consumables_count,
'accessories_count' => (int) $manufacturer->accessories_count,
'created_at' => Helper::getFormattedDateObject($manufacturer->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($manufacturer->updated_at, 'datetime'),
];

View file

@ -21,7 +21,7 @@ class StatuslabelsTransformer
public function transformStatuslabel (Statuslabel $statuslabel)
{
$array = [
'id' => e($statuslabel->id),
'id' => (int) $statuslabel->id,
'name' => e($statuslabel->name),
'type' => $statuslabel->getStatuslabelType(),
'color' => ($statuslabel->color) ? e($statuslabel->color) : null,

View file

@ -25,19 +25,19 @@ class SuppliersTransformer
$array = [
'id' => e($supplier->id),
'id' => (int) $supplier->id,
'name' => e($supplier->name),
'address' => ($supplier->address) ? e($supplier->address) : null,
'address2' => ($supplier->address2) ? e($supplier->address2) : null,
'city' => ($supplier->city) ? e($supplier->city) : null,
'state' => ($supplier->state) ? e($supplier->state) : null,
'country' =>($supplier->country) ? e($supplier->country) : null,
'fax' =>($supplier->fax) ? e($supplier->fax) : null,
'country' => ($supplier->country) ? e($supplier->country) : null,
'fax' => ($supplier->fax) ? e($supplier->fax) : null,
'phone' => ($supplier->phone) ? e($supplier->phone) : null,
'email' => ($supplier->email) ? e($supplier->email) : null,
'contact' => ($supplier->contact) ? e($supplier->contact) : null,
'assets_count' => $supplier->assets_count,
'licenses_count' => $supplier->licenses_count,
'assets_count' => (int) $supplier->assets_count,
'licenses_count' => (int) $supplier->licenses_count,
'created_at' => Helper::getFormattedDateObject($supplier->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($supplier->updated_at, 'datetime'),

View file

@ -22,13 +22,13 @@ class UsersTransformer
public function transformUser (User $user)
{
$array = [
'id' => e($user->id),
'id' => (int) $user->id,
'name' => e($user->first_name).' '.($user->last_name),
'firstname' => e($user->first_name),
'lastname' => e($user->last_name),
'username' => e($user->username),
'employee_num' => e($user->employee_num),
'manager' => ($user->manager) ? (new UsersTransformer)->transformUser($user->manager) : '',
'manager' => ($user->manager) ? (new UsersTransformer)->transformUser($user->manager) : null,
'groups' => $user->groups,
'jobtitle' => e($user->jobtitle),
'email' => e($user->email),
@ -40,11 +40,11 @@ class UsersTransformer
'permissions' => $user->decodePermissions(),
'activated' => ($user->activated =='1') ? true : false,
'two_factor_activated' => ($user->activated =='1') ? true : false,
'assets_count' => $user->assets_count,
'licenses_count' => $user->licenses_count,
'accessories_count' => $user->accessories_count,
'consumables_count' => $user->consumables_count,
'company' => ($user->company) ? ['id' => $user->company->id,'name'=> e($user->company->name)] : null,
'assets_count' => (int) $user->assets_count,
'licenses_count' => (int) $user->licenses_count,
'accessories_count' => (int) $user->accessories_count,
'consumables_count' => (int) $user->consumables_count,
'company' => ($user->company) ? ['id' => (int) $user->company->id,'name'=> e($user->company->name)] : null,
'created_at' => Helper::getFormattedDateObject($user->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($user->updated_at, 'datetime'),
'last_login' => Helper::getFormattedDateObject($user->last_login, 'datetime'),