mercredi 1 mars 2017

Laravel ModelFactory error when seeding

My ModelFactory:

<?php        

    $factory->define(App\Models\Customer::class, function (Faker\Generator $faker) {
        return [
            'name' => $faker->company,
            'email' => $faker->unique()->safeEmail,
            'status'=> $faker->numberBetween($min = 0, $max = 2),
            'slug'=> $faker->slug,
        ];
    });

Database seeder

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {

        $customers= factory(App\Models\Customer::class, 100)->create();

    }
}

When I run

php artisan db:seed

I get the error

  [Symfony\Component\Debug\Exception\FatalThrowableError]
  Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting '
  ]'

I've tried everything I can think of, but can't find the problem...



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire