Laravel Seed db: seed [Symfony \ Component \ Debug \ Exception \ FatalThrowableError] Fatal error: Class 'model' not found

0

I am using the FactoryModel tool to populate the database, for this I did the following:

I created the model: Php artisan make:model “Users” –m

I made the migration: php artisan migrate

Users Model

{

 use Authenticatable, Authorizable, CanResetPassword; 

 protected $table = 'users'; 

 protected $fillable = ['name', 'email', 'password','type']; 


 protected $hidden = [
    'password', 'remember_token',
 ];
}

in ModelFactory.php;

    $factory->define(App\User::class, function (Faker\Generator $faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->safeEmail,
        'password' => bcrypt('123'),
        'type' => 'administrador',
        'remember_token' => str_random(10),
    ];
});

in dataseSeeder.php;

public function run()
{
    model::unguard();

    factory('App\User','Administrador',3)->create();

    model::reguard();
}

people BD: php artisan db: seed

ERROR:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Fatal error: Class 'model' not found
    
asked by Daniel Alejandro Godoy Rios 03.04.2016 в 17:46
source

2 answers

1

It seems that in ModelFactory.php. you use App \ User :: class, but your model is called Users, also do not forget to configure your .evn.

    
answered by 03.04.2016 в 19:32
1

The error that shows is because you use 'model' in lowercase in the DatabaseSeeder.php file, the correct form according to the Laravel documentation, it is capitalized, since you are calling the class that references in use Illuminate\Database\Eloquent\Model :

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class DatabaseSeeder extends Seeder {

    public function run()
    {
        Model::unguard();

        // ....

        Model::reguard();
    }
}
    
answered by 04.04.2016 в 04:48