Skip to content

Commit

Permalink
Merge pull request #2 from zero-to-prod/docs/update-primary-example
Browse files Browse the repository at this point in the history
Update primary example with `UserFactory::factory([User::last_name => 'Doe'])->make()`
  • Loading branch information
zero-to-prod authored Oct 23, 2024
2 parents 4aab2aa + eb71431 commit 87af485
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class User

public $first_name;
public $last_name;

public static function factory(array $states = []): UserFactory
{
return new UserFactory($states);
}
}

class UserFactory
Expand Down Expand Up @@ -80,9 +85,10 @@ class UserFactory
}
}

$User = UserFactory::factory([User::last_name => 'Doe'])
$User = User::factory([User::last_name => 'Doe'])
->setFirstName('Jane')
->make();
// UserFactory::factory([User::last_name => 'Doe'])->make(); Also works

echo $User->first_name; // 'Jane'
echo $User->last_name; // 'Doe'
Expand Down

0 comments on commit 87af485

Please sign in to comment.