*/ final class UserFactory extends ModelFactory { CONST string PLAIN_PASSWORD = '12345678'; public function __construct() { parent::__construct(); } protected function getDefaults(): array { $factory = new PasswordHasherFactory([ 'auto' => ['algorithm' => 'auto'], ]); $hasher = $factory->getPasswordHasher('auto'); $hash = $hasher->hash(self::PLAIN_PASSWORD); return [ 'password' => $hash, 'roles' => [], 'groupsView' => 'card', 'username' => self::faker()->text(180), ]; } protected function initialize(): self { return $this // ->afterInstantiate(function(User $user): void {}) ; } protected static function getClass(): string { return User::class; } }