Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with parent_name generation in FakerPHP $faker->first_name() created full_name #935

Closed
zerovel666 opened this issue Jan 17, 2025 · 2 comments

Comments

@zerovel666
Copy link

Title: Error with parent_name generation in FakerPHP

Description:

I encountered an issue while using FakerPHP to generate random data for names. The parent_name is not being generated correctly according to the gender. Instead of appending the correct suffix (e.g., "ович" or "овна"), it seems to generate full names with incorrect formatting and unrelated names.

Название: Ошибка при генерации родительского имени в Cakephp

Описание:

Я столкнулся с проблемой при использовании Faker PHP для генерации случайных данных для имен. Родительское имя генерируется неправильно в соответствии с полом. Вместо добавления правильного суффикса (например, "ов" или "овна"), он, по-видимому, генерирует полные имена с неправильным форматированием и несвязанными именами.

<?php

namespace Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

class ClientFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array
     */
    public function definition()
    {
        return [
            'first_name' => $first_name = $this->faker->firstName($gender = $this->faker->randomElement(['male', 'female'])),
            'last_name' => $last_name = $this->faker->lastName(),
            'parent_name' => $parent_name = $this->faker->firstName($gender) . ($gender === 'male' ? 'ович' : 'овна'),
            'short_name' => $last_name . ' ' . strtoupper($first_name[0]) . strtoupper($parent_name[0]),
            'full_name' => "{$parent_name} {$first_name} {$last_name}", 
            'iin' => $this->faker->numberBetween(100000000000, 999999999999),
            'sex' => $gender === 'male' ? 1 : 0,
            'resident_bool' => true,
            'juridical_bool' => $this->faker->boolean(50),
            'address' => json_encode($this->faker->address()),
            'type_id' =>  $this->faker->randomElement(['1','2','3']),
            'birthday' => $this->faker->date(),
            'foreign_id' => $this->faker->numberBetween(100000,999999),
            'staffer' => $this->faker->randomElement([true,false,null]),
            'hire_date' => $this->faker->randomElement([$this->faker->date(),null]),
        ];
    }
}

Client::find(4)
= App\Models\Client\Client {#5973
id: 4,
first_name: "Рафаил",
last_name: "Кулагин",
parent_name: "Клементина Борисовна Фадеева",
short_name: "Харитонов Михаил Сергеевич",
full_name: "Георгий Владимирович Ефремов",
iin: "p",
sex: null,
resident_bool: null,
juridical_bool: true,
address: "{"test":"test"}",
type_id: 1,
birthday: "1977-08-25",
foreign_id: null,
updated_by: 1,
created_by: 1,
created_at: "2025-01-17 10:42:46+00",
updated_at: "2025-01-17 10:42:46+00",
staffer: null,
hire_date: null,
}

@pimjansen
Copy link

Please use the bug template

Copy link

stale bot commented Jan 31, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 1 week if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants