I 'm taking the FactoryModel Tool to populate the database for THIS Do the following :
Create Table :
Php artisan make:model “Users” –m
Up mysql :
php artisan migrate
migrate:
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password',60);
$table->enum('type',['Miembro','Administrador'])->default('Miembro');
$table->rememberToken();
$table->timestamps();
});
}
public function down()
{
Schema::drop('users');
}
}
Model Users
{
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();
}
migrate BD :
php artisan db:seed
ERROR: [Symfony\Component\Debug\Exception\FatalThrowableError] Fatal error: Class 'model' not found
I appreciate your help
DGR
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire