Skip to content

Commit da03fe3

Browse files
authored
Remove mention of $count in Factory Sequence documentation (laravel#10816)
$count is not useful for Sequences used with a callback, as it will always be `1`. The only use for $count is one internal to the Sequence class logic, when an array is passed to the sequence constructor and the count is used to modulo the index to avoid accessing values beyond the size of the array.
1 parent 35614d0 commit da03fe3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

eloquent-factories.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,14 @@ $users = User::factory()
319319
->create();
320320
```
321321

322-
Within a sequence closure, you may access the `$index` or `$count` properties on the sequence instance that is injected into the closure. The `$index` property contains the number of iterations through the sequence that have occurred thus far, while the `$count` property contains the total number of times the sequence will be invoked:
322+
Within a sequence closure, you may access the `$index` property on the sequence instance that is injected into the closure. The `$index` property contains the number of iterations through the sequence that have occurred thus far:
323323

324324
```php
325325
$users = User::factory()
326326
->count(10)
327-
->sequence(fn (Sequence $sequence) => ['name' => 'Name '.$sequence->index])
327+
->state(new Sequence(
328+
fn (Sequence $sequence) => ['name' => 'Name '.$sequence->index],
329+
))
328330
->create();
329331
```
330332

0 commit comments

Comments
 (0)