Skip to content

Commit

Permalink
More mapped fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Dec 23, 2023
1 parent eea154c commit 4c7dcbd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/Command/BakeFixtureFactoryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,23 @@ class BakeFixtureFactoryCommand extends BakeCommand
/**
* @var array
*/
protected $map = [
protected array $map = [
'string' => [
'name' => 'name',
'first_name' => 'firstName',
'last_name' => 'lastName',
'username' => 'userName',
'slug' => 'slug',
'email' => 'email',
'description' => 'words',
'postal_code' => 'postcode',
'city' => 'city',
'address' => 'address',
'url' => 'url',
'ip_address' => 'ipv4',
'currency' => 'currencyCode',
'phone_number' => 'phoneNumber',
'timezone' => 'timezone',
],
'float' => [
'latitude' => 'latitude',
Expand Down Expand Up @@ -589,7 +600,11 @@ protected function foreignKeys(AssociationCollection $associations): array
$keys = [];

foreach ($associations as $association) {
$keys[] = $association->getForeignKey();
$key = $association->getForeignKey();
if ($key === false) {
continue;
}
$keys = array_merge($keys, (array)$key);
}

return $keys;
Expand Down
4 changes: 3 additions & 1 deletion src/View/Helper/FactoryBakeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class FactoryBakeHelper extends Helper
public function defaultData(array $defaultData): string
{
$rows = [];
$indent = str_repeat(' ', 4 * 4);

foreach ($defaultData as $key => $value) {
$rows[] = "\t\t\t\t" . '\'' . $key . '\' => ' . $value . ',';
$rows[] = $indent . '\'' . $key . '\' => ' . $value . ',';
}

$string = implode(PHP_EOL, $rows);
Expand Down

0 comments on commit 4c7dcbd

Please sign in to comment.