diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index 5aa615675fee..1b9f93c625dd 100644 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -766,13 +766,21 @@ public function shift() /** * Shuffle the items in the collection. * + * @param int $seed * @return static */ - public function shuffle() + public function shuffle($seed = null) { $items = $this->items; - shuffle($items); + if (is_null($seed)) { + shuffle($items); + } else { + srand($seed); + usort($items, function ($a, $b) { + return rand(-1, 1); + }); + } return new static($items); }