0

im trying to insert records in my database using tinker but i have an error : Php warning : a non-numeric value encountered and no records are save.

My factory :

$factory->define(App\Donne::class, function (Faker\Generator $faker) {
return [

    'nom_destinataire' => $faker->firstName($gender = null|'male'|'female'),
    'adresse_destinataire' => $faker->address,                                             
    'code_postal' => $faker->postcode,
    'localite_destinataire' => $faker->country,
    'port'=>$faker->randomLetter,
];

My tinker command

factory(App\Donne::class, 1)->create();

Thanks for help

darkcast
  • 11
  • 2
  • 1
    Does your factory works within the code? It is not a tinker problem I believe, your usage does not seem right to me.. What is this `$faker->firstName($gender = null|'male'|'female')`? – nakov Nov 15 '19 at 10:56

1 Answers1

0

The examples in the package readme here are for demonstrating the available options that can be passed to a function

Faker\Provider\en_US\Person

title($gender = null|'male'|'female')     // 'Ms.'
titleMale                                 // 'Mr.'
titleFemale                               // 'Ms.'
suffix                                    // 'Jr.'
name($gender = null|'male'|'female')      // 'Dr. Zane Stroman'
firstName($gender = null|'male'|'female') // 'Maynard'
firstNameMale                             // 'Maynard'
firstNameFemale                           // 'Rachel'
lastName                                  // 'Zulauf'

DO NOT COPY PASTE, | means (either...or) in plain English

firstName function only accepts one optional argument, remove it if you want generated data to be either male or female randomly

$factory->define(App\Donne::class, function (Faker\Generator $faker) {
    return [
        'nom_destinataire' => $faker->firstName(),
        'adresse_destinataire' => $faker->address,
        'code_postal' => $faker->postcode,
        'localite_destinataire' => $faker->country,
        'port' => $faker->randomLetter,
    ];
});

Hope this helps

Salim Djerbouh
  • 10,719
  • 6
  • 29
  • 61