{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/11588","labels_url":"https://api.github.com/repos/laravel/framework/issues/11588/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/11588/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/11588/events","html_url":"https://github.com/laravel/framework/issues/11588","id":124177983,"number":11588,"title":"random(N) method should not produce error wnen number of models < N","user":{"login":"UnrulyNatives","id":6769986,"avatar_url":"https://avatars.githubusercontent.com/u/6769986?v=3","gravatar_id":"","url":"https://api.github.com/users/UnrulyNatives","html_url":"https://github.com/UnrulyNatives","followers_url":"https://api.github.com/users/UnrulyNatives/followers","following_url":"https://api.github.com/users/UnrulyNatives/following{/other_user}","gists_url":"https://api.github.com/users/UnrulyNatives/gists{/gist_id}","starred_url":"https://api.github.com/users/UnrulyNatives/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UnrulyNatives/subscriptions","organizations_url":"https://api.github.com/users/UnrulyNatives/orgs","repos_url":"https://api.github.com/users/UnrulyNatives/repos","events_url":"https://api.github.com/users/UnrulyNatives/events{/privacy}","received_events_url":"https://api.github.com/users/UnrulyNatives/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-12-29T08:00:30Z","updated_at":"2015-12-29T11:39:04Z","closed_at":null,"body":"When I start a query to get a certain number of random models\r\n\r\n        $object = Model::all()->random(10);\r\n\r\nI get this error:\r\n    local.ERROR: 'exception InvalidArgumentException' with message 'You requested 10 items, but there are only 1 items in the collection' in D:\\www\\!Chiny_2016\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Collection.php:584\r\n\r\nFeature suggestion:\r\nmaybe the `random` method should output as many as there is, instead of crashing?\r\n"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/167770186","html_url":"https://github.com/laravel/framework/issues/11588#issuecomment-167770186","issue_url":"https://api.github.com/repos/laravel/framework/issues/11588","id":167770186,"user":{"login":"UnrulyNatives","id":6769986,"avatar_url":"https://avatars.githubusercontent.com/u/6769986?v=3","gravatar_id":"","url":"https://api.github.com/users/UnrulyNatives","html_url":"https://github.com/UnrulyNatives","followers_url":"https://api.github.com/users/UnrulyNatives/followers","following_url":"https://api.github.com/users/UnrulyNatives/following{/other_user}","gists_url":"https://api.github.com/users/UnrulyNatives/gists{/gist_id}","starred_url":"https://api.github.com/users/UnrulyNatives/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UnrulyNatives/subscriptions","organizations_url":"https://api.github.com/users/UnrulyNatives/orgs","repos_url":"https://api.github.com/users/UnrulyNatives/repos","events_url":"https://api.github.com/users/UnrulyNatives/events{/privacy}","received_events_url":"https://api.github.com/users/UnrulyNatives/received_events","type":"User","site_admin":false},"created_at":"2015-12-29T11:39:04Z","updated_at":"2015-12-29T11:39:04Z","body":"Thx. \r\n\r\nIn the meantime I came up with a good scenario:\r\n\r\nSunday evening. Football game is about to start in 60 mins.\r\n- Honey, go to CVS and get me 10 bottles of my favorite beer, A-SAP! \r\n- Yes, sir!\r\n...1 hour later...\r\n- Darling, I am back!\r\n- Where's my beer?\r\n- Uh, sorry. There were only 8 bottles left on the shelf. You said 10, so I broght you nothing!\r\n\r\nNow my point is perfectly clear, I guess.! :)"}}