jeudi 15 octobre 2015

Laravel 5.1 - preg_replace(): Parameter mismatch, pattern is a string while replacement is an array

Learning Laravel and when trying to use a factory on the command line i get this error:

PHP warning: preg_replace(): Parameter mismatch, pattern is a string while replacement is an array in /Applications/MAMP/htdocs/breedr-laravel/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 671

The factory code is this:

$factory->define(App\Gecko::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->name,
        'aquisition_date' => $faker->date($format = 'Y-m-d', $max = 'now'),
        'morph' => $faker->word,
        'sex' => $faker->word,
        'genetics' => $faker->word,
        'bio' => $faker->paragraphs(3),
        'bred' => $faker->numberBetween(0, 1),
        'hatchling' => $faker->numberBetween(0, 1),
        'clutch' => $faker->randomDigitNotNull,
        'image' => 'image.jpg',
        'user_id' => $faker->randomDigitNotNull,
    ];
});

When I run $gecko = factory('App\Gecko')->make(); it loads on the terminal no problem, but when I run $gecko = factory('App\Gecko')->create(); I just get the error above.

I'm very new to this and don't understand what the problem is. If i've missed important code please let me know!

Andy



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire