sequence = $sequence; $this->count = count($sequence); } /** * Get the current count of the sequence items. * * @return int */ public function count(): int { return $this->count; } /** * Get the next value in the sequence. * * @param array $attributes * @param \Illuminate\Database\Eloquent\Model|null $parent * @return mixed */ public function __invoke($attributes = [], $parent = null) { return tap(value($this->sequence[$this->index % $this->count], $this, $attributes, $parent), function () { $this->index = $this->index + 1; }); } }