Comments (8)
Sorry I saw that you are WIP in some issues...would be great have the links in the relationships
from json-api.
Hey! Lets see if we can debug this together.
First thing to check - are you calling JsonApiResource::minimalAttributes()
anywhere?
Could you also please share with me the resources that aren't working for you?
from json-api.
Hi Tim, thank you for answer me
This is the resources
https://github.com/jonquintero/api-test-pest/blob/8593ed077c166a671aa3aaa9d1abe7c7901dd7de/app/Http/Resources/EmployeeResource.php#L1
from json-api.
if you see, I'm using 'department' => fn () => new DepartmentResource($this->department), and not DepartmentResource::minimalAttributes().
Why not? Because the behavior is so weird, only show the attributes from the first record and the others records disappear
from json-api.
Hi @jonquintero did you find any solution for not showing the attributes of relation, because I have the same problem, it only shows the id and the type and an empty object of meta?
from json-api.
Hi @DiarQoroviqi, unfortunately I couldn't, I had to remove the package and use https://laravel.com/docs/9.x/eloquent-resources
from json-api.
Hey folks, I believe this is cause by the relationship being null
and not a model. When your relation is nullable
, you should follow this pattern...
return [
'user' => fn () => optional($this->user, fn ($user) => new UserResource($user)),
];
This is documented: https://github.com/timacdonald/json-api#resource-relationships
Note: In an upcoming verison, this will be improved so you can just return the resource and not have to juggle it being null
.
from json-api.
I have the same problem
Not working
public function toRelationships(Request $request): array
{
return [
'services' => fn () => optional($this->services, fn ($services) => ServicesResource::collection($services)),
];
}
Not working
public function toRelationships(Request $request): array
{
return [
'services' => fn () => ServicesResource::collection($services),
];
}
Not working
public $relationships = [
'services' => ServicesResource::class,
];
from json-api.
Related Issues (20)
- Would you consider adding links to relationships in milestone for v1.x HOT 2
- To Many relationship wrong wrapped? HOT 7
- [Question] How to include tree relationships? HOT 7
- Getting empty results in browser
- Using with non Model resources. HOT 1
- Laravel 10 support HOT 1
- Laravel 10 support HOT 2
- Default include relationship HOT 1
- JsonApiServerImplementation 'final'`, doesn't allow custom implementations HOT 2
- Relationship attributes are not displayed in the response HOT 2
- Do this for James
- Lumen support? HOT 1
- Relationships not shown while having data HOT 5
- How to get from JsonResource to JsonApiResource HOT 1
- Type is plural HOT 1
- Relationship data is not shown as expected HOT 6
- Is the response following v1.0 or ? HOT 1
- laravel 10
- i now want some vegemite HOT 2
- Clarification for how to use with many to many
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-api.