src/Collection.php
public function partition($callback)
    {
        $partitions = [new static, new static];
        $callback   = $this->valueAccessor($callback);

        foreach ($this->items as $key => $item) {
            $partitions[(int) ! $callback($item)][$key] = $item;
        }

        return new static($partitions);
    }
public function partition($callback)
    {
        $partitions = [new static, new static];
        $callback   = $this->valueAccessor($callback);

        foreach ($this->items as $key => $item) {
            $partitions[(int) ! $callback($item)][$key] = $item;
        }

        return new static($partitions);
    }
public function partition ( $ callback ) { $ partitions = [ new static , new static ] ; $ callback = $ this -> valueAccessor ( $ callback ) ; foreach ( $ this -> items as $ key => $ item ) { $ partitions [ ( int ) ! $ callback ( $ item ) ] [ $ key ] = $ item ; } return new static ( $ partitions ) ; }
Partition the Collection into two Collections using the given callback or key.

Based on Laravel: Illuminate\Support\Collection.partition

@param callable|string $callback

@return static[static, static]
Partition the Collection into two Collections using the given callback or key .