{"action":"created","issue":{"url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/159","repository_url":"https://api.github.com/repos/cmgmyr/laravel-messenger","labels_url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/159/labels{/name}","comments_url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/159/comments","events_url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/159/events","html_url":"https://github.com/cmgmyr/laravel-messenger/issues/159","id":173844432,"number":159,"title":"userUnreadMessages gives 'Undefined offset: -1' ","user":{"login":"bstrx","id":1029105,"avatar_url":"https://avatars.githubusercontent.com/u/1029105?v=3","gravatar_id":"","url":"https://api.github.com/users/bstrx","html_url":"https://github.com/bstrx","followers_url":"https://api.github.com/users/bstrx/followers","following_url":"https://api.github.com/users/bstrx/following{/other_user}","gists_url":"https://api.github.com/users/bstrx/gists{/gist_id}","starred_url":"https://api.github.com/users/bstrx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bstrx/subscriptions","organizations_url":"https://api.github.com/users/bstrx/orgs","repos_url":"https://api.github.com/users/bstrx/repos","events_url":"https://api.github.com/users/bstrx/events{/privacy}","received_events_url":"https://api.github.com/users/bstrx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cmgmyr/laravel-messenger/labels/pending%20verification","name":"pending verification","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-08-29T18:50:37Z","updated_at":"2016-09-01T20:30:26Z","closed_at":"2016-09-01T20:30:26Z","body":"Hello, I get errors when using userUnreadMessages having 0 messages:\r\n```\r\nErrorException: Exception 'ErrorException' with message 'Undefined offset: -1' in /var/www/project/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1187\r\n\r\nSample stack trace\r\n…/var/www/project/vendor/laravel/framework/src/Illuminate/Support/\r\nCollection.php (1187)\r\n…/var/www/project/vendor/cmgmyr/messenger/src/Cmgmyr/Messenger/Models/\r\nThread.php (369)\r\n…ages called at /var/www/project/app/Http/Controllers/Api/\r\nMessagesController.php (32)\r\n```\r\n\r\nin this:\r\n```php\r\n        $i = count($messages) - 1;\r\n        while ($i) {\r\n            if ($messages[$i]->updated_at->gt($participant->last_read)) {\r\n                array_push($unread, $messages[$i]);\r\n            } else {\r\n                break;\r\n            }\r\n            --$i;\r\n        }\r\n```"},"comment":{"url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/comments/244202469","html_url":"https://github.com/cmgmyr/laravel-messenger/issues/159#issuecomment-244202469","issue_url":"https://api.github.com/repos/cmgmyr/laravel-messenger/issues/159","id":244202469,"user":{"login":"cmgmyr","id":4693481,"avatar_url":"https://avatars.githubusercontent.com/u/4693481?v=3","gravatar_id":"","url":"https://api.github.com/users/cmgmyr","html_url":"https://github.com/cmgmyr","followers_url":"https://api.github.com/users/cmgmyr/followers","following_url":"https://api.github.com/users/cmgmyr/following{/other_user}","gists_url":"https://api.github.com/users/cmgmyr/gists{/gist_id}","starred_url":"https://api.github.com/users/cmgmyr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmgmyr/subscriptions","organizations_url":"https://api.github.com/users/cmgmyr/orgs","repos_url":"https://api.github.com/users/cmgmyr/repos","events_url":"https://api.github.com/users/cmgmyr/events{/privacy}","received_events_url":"https://api.github.com/users/cmgmyr/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T20:30:26Z","updated_at":"2016-09-01T20:30:26Z","body":"@bstrx awesome! I'll be officially tagging this shortly - I'll update this issue once I do it, but I'm going to close it for now."}}
{"actor":{"display_login":"cmgmyr"}}