You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for raising this... I need to change the store method to getStore so that it is a lot less likely to clash. Also need to check through all the other methods to ensure there are no other potentially clashing names.
I'll fix this for the next release which will be 1.0.0-beta.1 but not sure when that will get tagged. in the meantime, you can fix by overloading this method on the adapter:
Hi,
I upgrade library from 0.11.1 to 1.0.0-alpha.2 version and I am having trouble with a relationship called "store".
{
"data": {
"type": "pos",
"attributes": {
"code": "pos_001",
"name": "Pos 001"
},
"relationships": {
"store": {
"data": { "type": "stores", "id": "40" }
}
}
}
}
As described in the documentation I define in my adapter the relationship:
protected function store () {
return $this->belongsTo ();
}
but this override a method in StoreAwareTrait :-(
How can I solve the problem without changing the name of the relationship?
Thanks in advance
Error stack trace:
[2018-05-18 08:30:49] local.ERROR: Type error: Argument 1 passed to CloudCreativity\LaravelJsonApi\Eloquent\AbstractRelation::withStore() must implement interface CloudCreativity\LaravelJsonApi\Contracts\Store\StoreInterface, instance of CloudCreativity\LaravelJsonApi\Eloquent\BelongsTo given, called in /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php on line 140 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Type error: Argument 1 passed to CloudCreativity\LaravelJsonApi\Eloquent\AbstractRelation::withStore() must implement interface CloudCreativity\LaravelJsonApi\Contracts\Store\StoreInterface, instance of CloudCreativity\LaravelJsonApi\Eloquent\BelongsTo given, called in /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php on line 140 at /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Store/StoreAwareTrait.php:40)
[stacktrace]
#0 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php(140): CloudCreativity\LaravelJsonApi\Eloquent\AbstractRelation->withStore(Object(CloudCreativity\LaravelJsonApi\Eloquent\BelongsTo))
#1 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Eloquent/AbstractAdapter.php(375): CloudCreativity\LaravelJsonApi\Adapter\AbstractResourceAdapter->related('store')
#2 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Adapter/AbstractResourceAdapter.php(91): CloudCreativity\LaravelJsonApi\Eloquent\AbstractAdapter->hydrateRelationships(Object(App\CustomerPos), Object(CloudCreativity\LaravelJsonApi\Object\Relationships), Object(Neomerx\JsonApi\Encoder\Parameters\EncodingParameters))
#3 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Store/Store.php(88): CloudCreativity\LaravelJsonApi\Adapter\AbstractResourceAdapter->create(Object(CloudCreativity\LaravelJsonApi\Object\ResourceObject), Object(Neomerx\JsonApi\Encoder\Parameters\EncodingParameters))
#4 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php(289): CloudCreativity\LaravelJsonApi\Store\Store->createRecord('pos', Object(CloudCreativity\LaravelJsonApi\Object\ResourceObject), Object(Neomerx\JsonApi\Encoder\Parameters\EncodingParameters))
#5 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php(98): CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController->doCreate(Object(CloudCreativity\LaravelJsonApi\Store\Store), Object(CloudCreativity\LaravelJsonApi\Http\Requests\ValidatedRequest))
#6 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(29): CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController->CloudCreativity\LaravelJsonApi\Http\Controllers\{closure}(Object(Illuminate\Database\MySqlConnection))
#7 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php(432): Illuminate\Database\Connection->transaction(Object(Closure))
#8 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Http/Controllers/JsonApiController.php(99): CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController->transaction(Object(Closure))
#9 [internal function]: CloudCreativity\LaravelJsonApi\Http\Controllers\JsonApiController->create(Object(CloudCreativity\LaravelJsonApi\Store\Store), Object(CloudCreativity\LaravelJsonApi\Http\Requests\ValidatedRequest), 'pos')
#10 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#11 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('create', Array)
#12 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\CustomerArea\Api\PosController), 'create')
#13 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\Routing\Route->runController()
#14 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Router.php(659): Illuminate\Routing\Route->run()
#15 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#16 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Http/Middleware/SubstituteBindings.php(70): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#17 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): CloudCreativity\LaravelJsonApi\Http\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#18 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#19 /home/vagrant/backoffice2/vendor/cloudcreativity/laravel-json-api/src/Http/Middleware/BootJsonApi.php(86): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#20 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): CloudCreativity\LaravelJsonApi\Http\Middleware\BootJsonApi->handle(Object(Illuminate\Http\Request), Object(Closure), 'customer')
#21 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#22 /home/vagrant/backoffice2/app/Http/Middleware/AuthenticateCustomer.php(34): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#23 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): App\Http\Middleware\AuthenticateCustomer->handle(Object(Illuminate\Http\Request), Object(Closure), 'customer_api')
#24 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#26 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Router.php(661): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#27 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#28 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Router.php(602): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#29 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Router.php(591): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#30 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#31 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#32 /home/vagrant/backoffice2/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(58): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#33 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 /home/vagrant/backoffice2/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#36 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#37 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#38 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#39 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#42 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#43 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#44 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#45 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#46 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#47 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(51): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#48 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#49 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#50 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#51 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#52 /home/vagrant/backoffice2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#53 /home/vagrant/backoffice2/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#54 {main}
"}
The text was updated successfully, but these errors were encountered: