{"action":"created","issue":{"url":"https://api.github.com/repos/baopham/laravel-dynamodb/issues/152","repository_url":"https://api.github.com/repos/baopham/laravel-dynamodb","labels_url":"https://api.github.com/repos/baopham/laravel-dynamodb/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/baopham/laravel-dynamodb/issues/152/comments","events_url":"https://api.github.com/repos/baopham/laravel-dynamodb/issues/152/events","html_url":"https://github.com/baopham/laravel-dynamodb/issues/152","id":356714927,"node_id":"MDU6SXNzdWUzNTY3MTQ5Mjc=","number":152,"title":"removeAttribute creates a dirty model","user":{"login":"thomasedwards","id":354995,"node_id":"MDQ6VXNlcjM1NDk5NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/354995?v=4","gravatar_id":"","url":"https://api.github.com/users/thomasedwards","html_url":"https://github.com/thomasedwards","followers_url":"https://api.github.com/users/thomasedwards/followers","following_url":"https://api.github.com/users/thomasedwards/following{/other_user}","gists_url":"https://api.github.com/users/thomasedwards/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasedwards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasedwards/subscriptions","organizations_url":"https://api.github.com/users/thomasedwards/orgs","repos_url":"https://api.github.com/users/thomasedwards/repos","events_url":"https://api.github.com/users/thomasedwards/events{/privacy}","received_events_url":"https://api.github.com/users/thomasedwards/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-09-04T08:58:50Z","updated_at":"2018-11-12T14:17:46Z","closed_at":"2018-11-10T16:49:42Z","author_association":"NONE","body":"**Describe the bug**\r\n\r\nWhen using `removeAttribute()`, followed by `save()`, it will save the model as it was before.\r\n\r\n```php\r\n    $model = new Model;\r\n    $model->oldThing = true;\r\n    $model->save();\r\n\r\n    // Later...\r\n\r\n    $model = new Model;\r\n    $model->newThing = true;\r\n    $organisation->removeAttribute('oldThing');\r\n    $model->save();\r\n\r\n    // $model has oldThing and newThing\r\n\r\n    // Later...\r\n\r\n    $model = new Model;\r\n    $organisation->removeAttribute('oldThing');\r\n    $model->save();\r\n\r\n    // $model has oldThing and newThing\r\n```\r\n\r\nIn [Eloquent](https://github.com/laravel/framework/blob/5.6/src/Illuminate/Database/Eloquent/Model.php), the model checks to see if it’s dirty before saving:\r\n\r\n```php\r\n    // If the model already exists in the database we can just update our record\r\n    // that is already in this database using the current IDs in this \"where\"\r\n    // clause to only update this model. Otherwise, we'll just insert them.\r\n    if ($this->exists) {\r\n        $saved = $this->isDirty() ?\r\n                    $this->performUpdate($query) : true;\r\n    }\r\n```\r\n\r\nWhich would solve the case where `removeAttributes()` is run and then a `save()` is performed anyway, such as on an `update`-type of request, but it wouldn’t solve the adding/removing at the same time problem.\r\n\r\n**Version info**\r\n\r\n* Laravel: 5.6\r\n* Library: latest"},"comment":{"url":"https://api.github.com/repos/baopham/laravel-dynamodb/issues/comments/437897157","html_url":"https://github.com/baopham/laravel-dynamodb/issues/152#issuecomment-437897157","issue_url":"https://api.github.com/repos/baopham/laravel-dynamodb/issues/152","id":437897157,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzg5NzE1Nw==","user":{"login":"thomasedwards","id":354995,"node_id":"MDQ6VXNlcjM1NDk5NQ==","avatar_url":"https://avatars2.githubusercontent.com/u/354995?v=4","gravatar_id":"","url":"https://api.github.com/users/thomasedwards","html_url":"https://github.com/thomasedwards","followers_url":"https://api.github.com/users/thomasedwards/followers","following_url":"https://api.github.com/users/thomasedwards/following{/other_user}","gists_url":"https://api.github.com/users/thomasedwards/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasedwards/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasedwards/subscriptions","organizations_url":"https://api.github.com/users/thomasedwards/orgs","repos_url":"https://api.github.com/users/thomasedwards/repos","events_url":"https://api.github.com/users/thomasedwards/events{/privacy}","received_events_url":"https://api.github.com/users/thomasedwards/received_events","type":"User","site_admin":false},"created_at":"2018-11-12T14:17:46Z","updated_at":"2018-11-12T14:17:46Z","author_association":"NONE","body":"Just removed 7 lines of code already from one project 👌\r\n\r\nThank you very much!"}}
{"actor":{"display_login":"thomasedwards"}}