{"action":"created","issue":{"url":"https://api.github.com/repos/Crinsane/LaravelShoppingcart/issues/437","repository_url":"https://api.github.com/repos/Crinsane/LaravelShoppingcart","labels_url":"https://api.github.com/repos/Crinsane/LaravelShoppingcart/issues/437/labels{/name}","comments_url":"https://api.github.com/repos/Crinsane/LaravelShoppingcart/issues/437/comments","events_url":"https://api.github.com/repos/Crinsane/LaravelShoppingcart/issues/437/events","html_url":"https://github.com/Crinsane/LaravelShoppingcart/issues/437","id":304080179,"number":437,"title":"Updating options overriding others","user":{"login":"codeasashu","id":1492350,"avatar_url":"https://avatars1.githubusercontent.com/u/1492350?v=4","gravatar_id":"","url":"https://api.github.com/users/codeasashu","html_url":"https://github.com/codeasashu","followers_url":"https://api.github.com/users/codeasashu/followers","following_url":"https://api.github.com/users/codeasashu/following{/other_user}","gists_url":"https://api.github.com/users/codeasashu/gists{/gist_id}","starred_url":"https://api.github.com/users/codeasashu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeasashu/subscriptions","organizations_url":"https://api.github.com/users/codeasashu/orgs","repos_url":"https://api.github.com/users/codeasashu/repos","events_url":"https://api.github.com/users/codeasashu/events{/privacy}","received_events_url":"https://api.github.com/users/codeasashu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-10T15:46:32Z","updated_at":"2018-03-10T16:03:56Z","closed_at":"2018-03-10T16:03:56Z","author_association":"NONE","body":"I am trying to update/add an option using\r\n```php\r\nCart::update($rowId, ['options' => ['a' => [1,2,3]]);\r\n```\r\nCart now shows up having:\r\n![image](https://user-images.githubusercontent.com/1492350/37243956-f32e549c-24a7-11e8-821c-2a5c24e50a6a.png)\r\n\r\nHowever, I want to update another option b, using\r\n```php\r\nCart::update($rowId, ['options' => ['b' => [4,5,6]]);\r\n```\r\nwhich removes option `a` and now my cart option  becomes\r\n![image](https://user-images.githubusercontent.com/1492350/37243970-255cef1e-24a8-11e8-9d0a-3db10a95039c.png)\r\n\r\nHow do I \"append\" an option to existing one? I tried using array_merge but it seems to I have to user `toArray` method to `CartItemOptions` which then will remove any Custom class I have in option."},"comment":{"url":"https://api.github.com/repos/Crinsane/LaravelShoppingcart/issues/comments/372040834","html_url":"https://github.com/Crinsane/LaravelShoppingcart/issues/437#issuecomment-372040834","issue_url":"https://api.github.com/repos/Crinsane/LaravelShoppingcart/issues/437","id":372040834,"user":{"login":"codeasashu","id":1492350,"avatar_url":"https://avatars1.githubusercontent.com/u/1492350?v=4","gravatar_id":"","url":"https://api.github.com/users/codeasashu","html_url":"https://github.com/codeasashu","followers_url":"https://api.github.com/users/codeasashu/followers","following_url":"https://api.github.com/users/codeasashu/following{/other_user}","gists_url":"https://api.github.com/users/codeasashu/gists{/gist_id}","starred_url":"https://api.github.com/users/codeasashu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeasashu/subscriptions","organizations_url":"https://api.github.com/users/codeasashu/orgs","repos_url":"https://api.github.com/users/codeasashu/repos","events_url":"https://api.github.com/users/codeasashu/events{/privacy}","received_events_url":"https://api.github.com/users/codeasashu/received_events","type":"User","site_admin":false},"created_at":"2018-03-10T16:03:56Z","updated_at":"2018-03-10T16:03:56Z","author_association":"NONE","body":"Nevermind, solved it.\r\n\r\nI was not thinking clearly. Obviously, It will override, unless I am appending it to existing options. So I have now changed my code to:\r\n\r\n```php\r\n$options = Cart::get($rowId)->options;\r\n$options['b'] = [4,5,6];\r\nCart::update($rowId, compact('options')); // Or ['options' => $options]\r\n```\r\n\r\nThis safely lets me append my options. Thank you for wonderful library"}}
{"actor":{"display_login":"codeasashu"}}