I'm studying laravel in version 5.2 and running the php artisan command db: seed returns the following error:
[InvalidArgumentException]
Unable to locate factory with name [default] [CodePub \ Models \ User].
<?php
use Illuminate\Database\Seeder;
class UsersRolesPermissionsSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$user = factory(\CodePub\Models\User::class)->create([
'name' => 'Admin da Silva',
'email' => '[email protected]',
'password' => bcrypt(123456)
]);
$roleAdmin = factory(\CodePub\Models\Role::class)->create([
'name' => 'Admin',
'description' => 'System Administrator'
]);
$user->addRole($roleAdmin);
$userManager = factory(\CodePub\Models\User::class)->create([
'name' => 'Manager da Silva',
'email' => '[email protected]',
'password' => bcrypt(123456)
]);
$roleManager = factory(\CodePub\Models\Role::class)->create([
'name' => 'Manager',
'description' => 'System Manager'
]);
$userManager->addRole($roleManager);
$userSupervisor = factory(\CodePub\Models\User::class)->create([
'name' => 'Supervisor da Silva',
'email' => '[email protected]',
'password' => bcrypt(123456)
]);
$roleSupervisor = factory(\CodePub\Models\Role::class)->create([
'name' => 'Supervisor',
'description' => 'System Supervisor'
]);
$userSupervisor->addRole($roleSupervisor);
}
}
DatabaseSeeder.php
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
// $this->call(UserTableSeeder::class);
$this->call(UsersRolesPermissionsSeeder::class);
}
}