Comments (5)
Hello!
You have to write all this yourself.
A few ideas:
- Override the method actionCreate in the controller - UserController
- Override the method create in the model - \App\Model\User
- Add an observer similarly by App\Observers\CreatedByAndUpdatedByObserver or App\Observers\LoggerObserver
You may also need documentation about the validator:
https://laravel.com/docs/5.6/validation#rule-required-if
from bootstrapi.
Hi @kot13,
I was able to implement following your suggestions, thanks!!!
I was looking at "?include=relationEntity" for a related entity but doing some tests and checking the code I was unable to find anything.
Can you please drive me about this feature?
Thanks
Maurizio
from bootstrapi.
If you execute the query:
http://hostname.local/api/user/1?include=role
you will get:
{
"data": {
"type": "user",
"id": "1",
"attributes": {
"full_name": "Администратор",
"email": "[email protected]",
"role_id": 1,
"created_at": "2017-07-20T22:39:57+0000",
"updated_at": "2017-07-20T22:39:57+0000",
"created_by": null,
"updated_by": null,
"status": 1
},
"relationships": {
"role": {
"data": {
"type": "role",
"id": "1"
}
}
},
"links": {
"self": "http://hostname.local/api/user/1"
}
},
"included": [
{
"type": "role",
"id": "1",
"attributes": {
"name": "admin",
"description": "Администратор",
"created_at": "2017-07-20T22:39:56+0000",
"updated_at": "2017-07-20T22:39:56+0000",
"created_by": null,
"updated_by": null
},
"relationships": {
"rights": {
"data": []
}
}
}
]
}
All code in jsonapi library by neomerx and Eloquent ORM.
To look it is in:
\App\Schema\UserSchema::getRelationships
and
\App\Model\User::role
from bootstrapi.
Hi @kot13 ,
thanks for the feedback. I'm able to see the relationship as defined in the files but I didn't see the included as result in output.
I'll dig about the reason.
Thanks
Maurizio
from bootstrapi.
Hi!
I'll dig about the reason.
Look at this code:
https://github.com/kot13/bootstrapi/blob/master/app/src/Common/JsonApiEncoder.php
37-38 lines
from bootstrapi.
Related Issues (12)
- Adding composer.lock
- Add new entities to DB schema - support for user hierarchy HOT 1
- Add new entities to DB schema - support for external auth HOT 1
- Let's use Config component from Symfony HOT 3
- Unify AccessToken and RefreshToken HOT 1
- Question: Shall adding foreign key constraint in `access_tokens` table for `user_id` column be an additional overhead HOT 1
- Switch from 'email' to 'identity' for token request
- "Trailing data" error HOT 1
- конфиги HOT 4
- username <-> email misleading usage HOT 1
- Add new entities to DB schema HOT 1
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 bootstrapi.