Saving model with relations
See original GitHub issueHi, is there a way to save a models data with related models? I have a model User and it has a Profile and a Role.
I’m using backbone on the client side and i’m making a put to edit user info:
var userData = {
"email": "info@luisbravoa.com",
"Profile": {
"firstname": "luis",
"lastname": "bravo"
},
"Role": {
"user_id": "1",
"role_id": "3"
}
} ;
How can i specified in the save method to save also related models, something like this:
User.forge({id: id})
.save(userData, { withRealated: true})
.then(function(model){
// weeee
})
.otherwise(function(error){
// :(
});
thanks very much!
Issue Analytics
- State:
- Created 10 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
How to save Eloquent Model with relations in one go?
When saving a model with relations we do something like this; $ship = new Ship; $ship->name = 'Enterprise'; $ship->registry = 'ncc-1701D'; $ship->save(); ...
Read more >Laravel Saving A Model And Relationships - Stack Overflow
I'm trying to update the Model Years with new Data, but can't seem the get it done. I tried the following: $movies =...
Read more >Laravel saving model with relationship - Laracasts
Laravel saving model with relationship. Hi guys, I'm kinda new to laravel and I have a question. I have an Order model and...
Read more >Saving Models and Their Relationships with JSON API
So the real question becomes: is there a correct way to save a model and all its relationships included in a single post...
Read more >Eloquent: Relationships - The PHP Framework For Web Artisans
Inserting & Updating Related Models. The save Method; The create Method; Belongs To Relationships; Many To Many Relationships. Touching Parent Timestamps ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is this feature in development? It’s hard to tell by looking at #552
I agree. I would also like to have this functionality.