getAliasedProperties() and getHideProperties() are ignored in relationships
M0S4YSH3LL0 opened this issue · comments
WorkerTransformer
`<?php namespace App\Models\Transformer;
use App\Models\Worker;
use NilPortugues\Api\Mappings\JsonApiMapping;
class WorkerTransformer implements JsonApiMapping
{
/**
* {@inheritdoc}
/
public function getClass()
{
return Worker::class;
}
/*
* {@inheritdoc}
/
public function getAlias()
{
return 'worker';
}
/*
* {@inheritdoc}
/
public function getAliasedProperties()
{
return [
'wrk_forename' => 'forename',
'wrk_surname' => 'surname',
];
}
/*
* {@inheritdoc}
/
public function getHideProperties()
{
return [
'wrk_department_id',
'wrk_homeoffice',
'wrk_room_id',
];
}
/*
* {@inheritdoc}
/
public function getIdProperties()
{
return ['wrk_worker_id'];
}
/*
* {@inheritdoc}
/
public function getUrls()
{
return [
'self' => ['name' => 'api.v2.worker.show', 'as_id' => 'wrk_worker_id']
];
}
/*
* {@inheritdoc}
*/
public function getRelationships()
{
return [
];
}
/**
* List the fields that are mandatory in a persitence action (POST/PUT).
* If empty array is returned, all fields are mandatory.
*/
public function getRequiredProperties()
{
return [];
}
}`
Request on eg.: hardware, which is related to workers, outputs:
{ "data": { "type": "hardware", "id": "TEST456", "attributes": { "hw_bill": null, "hw_inventory_id": "TEST456", "hw_owner_company_id": 1, "hw_owner_department_id": 1, "hw_user_department_id": 1, "hw_user_worker_id": 5, "serialkey": "SERIAL4THEWIN", "title": "Cherry", "type": "Tastatur" }, "links": { "self": { "href": "http://127.0.0.1:8000/api/v2/hardware/TEST456" }, "user": { "href": "http://127.0.0.1:8000/api/v2/worker/5" }, "owner_dept": { "href": "http://127.0.0.1:8000/api/v2/department/1" }, "owner_comp": { "href": "http://127.0.0.1:8000/api/v2/company/1" } }, "relationships": { "worker": { "data": { "type": "worker", "id": "5" } }, "department": { "data": { "type": "department", "id": "1" } }, "company": { "data": { "type": "company", "id": "1" } } } }, "included": [ { "type": "worker", "id": "5", "attributes": { **"wrk_forename"**: "test3", "wrk_surname": "TESTTEST", "wrk_department_id": 1, "wrk_homeoffice": true, "wrk_room_id": 1 }, "links": { "self": { "href": "http://127.0.0.1:8000/api/v2/worker/5" } } }, { "type": "department", "id": "1", "attributes": { "department": "Entwicklung", "dept_floor_id": 3 }, "links": { "self": { "href": "http://127.0.0.1:8000/api/v2/department/1" } } }, { "type": "company", "id": "1", "attributes": { "company": "GermanPersonnel", "com_building_id": 1 } } ], "links": { "self": { "href": "http://127.0.0.1:8000/api/v2/hardware/TEST456" } }, "jsonapi": { "version": "1.0" } }
The properties like 'wrk_homeoffice' which should be hidden, are shown
the properties like 'wrk_forename' aren't aliased to 'forename'
any suggestions?