3
I am studying Laravel in version 5.2 and when running the command php Artisan 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);
}
}