-
Hey! I'm trying to understand how to use this package with models. Let's say i have a PostData object with relationships like this: $postData = PostData {
+title: "Post title",
+content: 'Post Content',
+user: UserData {
name: 'User name',
email: 'User email'
}
} In the db it would be to tables connected with a foreign key. If i now wanted to update the title and save it to the database, how would i do that? How to convert the DTO back to a model for updating? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
@rrrrando you can do something like From a request : call or bind the model and then insert what you want from the object class SongController{
...
public function update(
Song $model, // the model
SongData $songData //the object
){
$model->update(['title' => $songData->title]);
return
}
} for more information, you can see how to update a model and the difference between 'update' to 'save' method |
Beta Was this translation helpful? Give feedback.
@rrrrando you can do something like From a request :
call or bind the model and then insert what you want from the object
for more information, you can see how to update a model and the difference between 'update' to 'save' method