Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Repeat a string
<?php str_repeat(string $string, int $times): string
<?php $this->addImport($model, $reference->fullyQualifiedNamespace() . '\\' . $class);
if ($key === 'id') {
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
$definition .= sprintf('%s::factory()', $class);
$definition .= ',' . PHP_EOL;
} else {
<?php $definition .= sprintf('%s::factory()', $class);
$definition .= ',' . PHP_EOL;
} else {
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
$definition .= sprintf('%s::factory()->create()->%s', $class, $key);
$definition .= ',' . PHP_EOL;
}
<?php $reference = $this->fullyQualifyModelReference($class) ?? $model;
$this->addImport($model, $reference->fullyQualifiedNamespace() . '\\' . $class);
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
$definition .= sprintf('%s::factory()', $class);
$definition .= ',' . PHP_EOL;
} elseif (in_array($column->dataType(), ['enum', 'set']) && !empty($column->attributes())) {
<?php $definition .= ',' . PHP_EOL;
} elseif (in_array($column->dataType(), ['enum', 'set']) && !empty($column->attributes())) {
$faker = FakerRegistry::fakerData($column->name()) ?? FakerRegistry::fakerDataType($column->dataType());
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
$definition .= '$this->faker->' . $faker;
$definition .= ',' . PHP_EOL;
$definition = str_replace(
<?php );
} elseif (in_array($column->dataType(), ['decimal', 'double', 'float'])) {
$faker = FakerRegistry::fakerData($column->name()) ?? FakerRegistry::fakerDataType($column->dataType());
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
$definition .= '$this->faker->' . $faker;
$definition .= ',' . PHP_EOL;
<?php $definition = str_replace(
"/** {$column->dataType()}_attributes **/",
implode(', ', [$scale, 0, (str_repeat(9, $precision - $scale) . '.' . str_repeat(9, $scale))]),
$definition
);
} elseif (in_array($column->dataType(), ['json', 'jsonb'])) {
<?php );
} elseif (in_array($column->dataType(), ['json', 'jsonb'])) {
$default = $column->defaultValue() ?? '{}';
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => '{$default}'," . PHP_EOL;
} elseif ($column->dataType() === 'morphs') {
if ($column->isNullable()) {
continue;
<?php if ($column->isNullable()) {
continue;
}
$definition .= sprintf('%s%s => $this->faker->%s,%s', str_repeat(self::INDENT, 3), "'{$column->name()}_id'", FakerRegistry::fakerDataType('id'), PHP_EOL);
$definition .= sprintf('%s%s => $this->faker->%s,%s', str_repeat(self::INDENT, 3), "'{$column->name()}_type'", FakerRegistry::fakerDataType('string'), PHP_EOL);
} elseif ($column->dataType() === 'rememberToken') {
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
<?php continue;
}
$definition .= sprintf('%s%s => $this->faker->%s,%s', str_repeat(self::INDENT, 3), "'{$column->name()}_id'", FakerRegistry::fakerDataType('id'), PHP_EOL);
$definition .= sprintf('%s%s => $this->faker->%s,%s', str_repeat(self::INDENT, 3), "'{$column->name()}_type'", FakerRegistry::fakerDataType('string'), PHP_EOL);
} elseif ($column->dataType() === 'rememberToken') {
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
$definition .= 'Str::random(10)';
<?php $definition .= sprintf('%s%s => $this->faker->%s,%s', str_repeat(self::INDENT, 3), "'{$column->name()}_id'", FakerRegistry::fakerDataType('id'), PHP_EOL);
$definition .= sprintf('%s%s => $this->faker->%s,%s', str_repeat(self::INDENT, 3), "'{$column->name()}_type'", FakerRegistry::fakerDataType('string'), PHP_EOL);
} elseif ($column->dataType() === 'rememberToken') {
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
$definition .= 'Str::random(10)';
$definition .= ',' . PHP_EOL;
} else {
<?php $definition .= 'Str::random(10)';
$definition .= ',' . PHP_EOL;
} else {
$definition .= str_repeat(self::INDENT, 3) . "'{$column->name()}' => ";
$type = $column->dataType();
if ($column->isUnsigned()) {