Skip to content

Commit 41efa02

Browse files
Minor fix to the AsCollection Option example (#10365)
To avoid confusion, the option constructor should receive an `array`, not each array member values. This is because `mapInto` and `map` will receive the item array completely.
1 parent b277950 commit 41efa02

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

eloquent-mutators.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,15 +480,18 @@ use JsonSerializable;
480480

481481
class Option implements Arrayable, JsonSerializable
482482
{
483+
public string $name;
484+
public mixed $value;
485+
public bool $isLocked;
486+
483487
/**
484488
* Create a new Option instance.
485489
*/
486-
public function __construct(
487-
public string $name,
488-
public mixed $value,
489-
public bool $isLocked = false
490-
) {
491-
//
490+
public function __construct(array $data)
491+
{
492+
$this->name = $data['name'];
493+
$this->value = $data['value'];
494+
$this->isLocked = $data['is_locked'];
492495
}
493496

494497
/**

0 commit comments

Comments
 (0)