nilportugues / laravel5-jsonapi

Laravel 5 JSON API Transformer Package
http://nilportugues.com
MIT License
311 stars 70 forks source link

Laravel 5.2 - "Argument 1 passed to MappingFactory::fromArray() must be of the type array, string given" #122

Open victorsferreira opened 7 years ago

victorsferreira commented 7 years ago

I'm setting up an example application as documented on Github and I get this error:

FatalThrowableError in MappingFactory.php line 93:
Type error: Argument 1 passed to NilPortugues\Api\Mapping\MappingFactory::fromArray() must be of the type array, string given, called in /var/www/html/..../vendor/nilportugues/laravel5-json-api/src/NilPortugues/Laravel5/JsonApi/Mapper/Mapper.php on line 24

I just the default Employees and Orders resources.

By the way, I had to add these lines to EmployeesTransformer

   public function getRequiredProperties()
    {
        return [];
    }

And namespace App\Http\Controllers\Api; to the namespace of EmployeesController.

Another informations:

The transformers are located in App/Model/Api The models are located in App/Model/Database The controllers in App/Http/Controllers/Api

Anything else I should provide (the code, apart from what i posted above is exactly the same as in the documentation) ?

victorsferreira commented 7 years ago

Alright just found the error:

I named OrdersTransformer as OrdersTransformers