jeudi 31 août 2017

BadMethodCallException App\User::create() when seeding with zizaco

I'm having an error when seeding to the database using laravel 5.5 the error message is below and there is my users class and my seeder class. What is happening is that one record is being inserted at a time when calling db:seed but after the first call it says BadMethodException rest below

[BadMethodCallException]
Call to undefined method App\User::create()

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zizaco\Entrust\Traits\EntrustUserTrait;
use Eloquent;

class User extends Eloquent
{
    use EntrustUserTrait;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

<?php

use App\User;
use Faker\Factory as Faker;
use Illuminate\Database\Seeder;

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {       
        foreach (range(1, 100) as $index) {
            $faker = Faker::create();
            $user = User::create([
                'name' => $faker->firstName . ' ' . $faker->lastName,
                'email' => $faker->email,
                'password' => bcrypt('secret')
            ]);
        }
    }
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vNqp8i
via IFTTT

Aucun commentaire:

Enregistrer un commentaire