替换所有数据

@param  array  $items
170223
public function replace(array $items = [])
    {
        $this->items = [];

        foreach ($items as $key => $item) {
            $this->set($key, $item);
        }
    }
238285
public function setItems($items)
    {
        if (! is_array($items)) {
            $items = func_get_args();
        }

        $this->addBody($items);

        return $this;
    }
183527
private function checkItems($items)
    {
        foreach ($items as $item) {
            if ($this->isItemValid($item)) {
                continue;
            }

            throw new \InvalidArgumentException(sprintf(
                'At least one item in collection "%s" is invalid.',
                get_class($this)
            ));
        }
    }
949718
public function add(array $items) {
		
		foreach($items as $name => $object) {
			$this->set($name, $object);
		}
		
		return $this;
	}
87956
protected function processItems(array $items)
    {
        $processedItems = [];

        foreach ($items as $entry) {
            $processedItems[] = ModelFactory::make($entry);
        }

        $this->items = new ModelCollection($processedItems);
    }
353310
public function addRows($items)
    {
        foreach ($items as $item) {
            $this->_rows[] = $this->addRow($item);
        }
        $this->_currentRow = null;
    }
553033
public function filter(array $items, array $filters): array
    {
        if (empty($filters)) {
            // no filters means return all items
            return $items;
        }

        return array_filter($items, function ($item) use ($filters) {
            foreach ($filters as $filter) {
                $value = $this->extractValue($item, $filter->getField());
                if (!$this->valueMatchesFilter($value, $filter)) {
                    // all filters must pass so any failure means we
                    // can stop checking this item immediately.
                    return false;
                }
            }

            return true;
        });
    }
535840
public function foreverMany(array $items)
    {
        if (! method_exists($this->store, 'foreverMany')) {
            array_map([$this, 'forever'], array_keys($items), array_values($items));
        } else {
            $items = array_combine($this->tagKeys(array_keys($items)), array_values($items));

            $this->store->foreverMany($items);
        }
    }
168118
public function order($items)
	{
		$this->order = [];

		if (!empty($items)) {
			$this->addOrder($items);
		}

		return $this;
	}
1188136
public function items($items)
    {
        if ($items instanceof Closure) {
            $items = $items();
        }

        array_map(array($this, 'item'), (array) $items);

        return $this;
    }
218641
public function setItems(array $items)
    {
        $items = $this->getArrayableItems($items);

        foreach ($items as $item) {
            //Ensure the correct type is provided
            $this->checkType($item);
        }

        $this->items = $items;

        return $this;
    }
1143659
public function process(array $items)
    {
        $total = count($items);
        for ($i = 1; $i < $total; $i++) {
            for ($j = 0; $j < $total - $i; $j++) {
                if (!$items[$j]->getDate() || !$items[$j + 1]->getDate()) {
                    continue;
                }
                if ($items[$j]->getDate()->getTimestamp() > $items[$j + 1]->getDate()->getTimestamp()) {
                    continue;
                }
                $aux = $items[$j + 1];
                $items[$j + 1] = $items[$j];
                $items[$j] = $aux;
            }
        }

        return $items;
    }
172720
public function addAll(array $items) : Set
    {
        $values = $this->_pushAll($items);
        $this->setValues($values);
        return $this;
    }
887033
public function loadFromArray(array $items)
    {
        foreach ($items as $item) {
            if (is_array($item) && ! empty($item)) {
                $this->add($item);
            }
        }

        return $this;
    }
439254
public function remove( ...$items )
	{

		foreach ( $items as $item )
		if ( ( $index = $this->indexOf( $item ) ) !== null )
			unset( $this->items[ $index ] );

		return $this;
	}
797695
public function setItems($items)
    {
        foreach ($items as $item) {
            $item->setGallery($this);
        }
        $this->items = $items;

        return $this;
    }
362934
public function updateItemsData($items)
    {
        $items->each(function ($item) {
            CartItem::where('id', $item->id)->update([
                'name' => $item->name,
                'price' => $item->price,
                'image' => $item->image,
            ]);
        });
    }