Upgrade to 3.6.6
This commit is contained in:
@@ -870,6 +870,25 @@ class Collection extends Iterator implements Countable
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new collection consisting of random elements,
|
||||
* from the original collection, shuffled or ordered
|
||||
*
|
||||
* @param int $count
|
||||
* @param bool $shuffle
|
||||
* @return static
|
||||
*/
|
||||
public function random(int $count = 1, bool $shuffle = false)
|
||||
{
|
||||
if ($shuffle) {
|
||||
return $this->shuffle()->slice(0, $count);
|
||||
}
|
||||
|
||||
$collection = clone $this;
|
||||
$collection->data = A::random($collection->data, $count);
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an element from the array by key
|
||||
*
|
||||
|
Reference in New Issue
Block a user