NilPortugues\Api\Mappings\ApiMapping::getRequiredProperties Error
alochym01 opened this issue · comments
i follow the guide on github, and when i run php artisan route:list, i get the errors
PHP Fatal error: Class App\Model\Api\EmployeesTransformer contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (NilPortugues\Api\Mappings\ApiMapping::getRequiredProperties) in /home/hadn/Laravel/learning_bootstrap_v4/laravel/app/Model/Api/EmployeesTransformer.php on line 102
[Symfony\Component\Debug\Exception\FatalErrorException]
Class App\Model\Api\EmployeesTransformer contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (NilPortugues\Api\Mappings\ApiMapping::getRequiredProperties)
thi is my EmployeesTranformer:
<?php namespace App\Model\Api;
use App\Model\Database\Employees;
use NilPortugues\Api\Mappings\JsonApiMapping;
class EmployeesTransformer implements JsonApiMapping
{
/**
* Returns a string with the full class name, including namespace.
*
* @return string
*/
public function getClass()
{
return Employees::class;
}
/**
* Returns a string representing the resource name
* as it will be shown after the mapping.
*
* @return string
*/
public function getAlias()
{
return 'employee';
}
/**
* Returns an array of properties that will be renamed.
* Key is current property from the class.
* Value is the property's alias name.
*
* @return array
*/
public function getAliasedProperties()
{
return [
'last_name' => 'surname',
];
}
/**
* List of properties in the class that will be ignored by the mapping.
*
* @return array
*/
public function getHideProperties()
{
return [
'attachments'
];
}
/**
* Returns an array of properties that are used as an ID value.
*
* @return array
*/
public function getIdProperties()
{
return ['id'];
}
/**
* Returns a list of URLs. This urls must have placeholders
* to be replaced with the getIdProperties() values.
*
* @return array
*/
public function getUrls()
{
return [
'self' => ['name' => 'employees.show', 'as_id' => 'id'],
'employees' => ['name' => 'employees.index'],
'employee_orders' => ['name' => 'employees.orders', 'as_id' => 'id']
];
}
/**
* Returns an array containing the relationship mappings as an array.
* Key for each relationship defined must match a property of the mapped class.
*
* @return array
*/
public function getRelationships()
{
return [];
}
}
my package:
[hadn@rad-hadn4 laravel]$ cat composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"doctrine/dbal": "^2.5",
"nilportugues/laravel5-json-api": "^2.4"
},
I'm sorry, this is a bug in the documentation.
Add the following piece to your code:
/**
* {@inheritdoc}
*/
public function getRequiredProperties()
{
return [];
}
Please, update the documentation