i am trying to give roles to the users .i tried working with packages but wasn't successful so i was following a youtube video,everything went fine until i tried to seed the databse. [ReflectionException]
when i was trying a package entrust,i was facing a similar problem. `
Class RoleTableSeeder does not exist
my DatabaseSeeder file is
` <?php `
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{ /** * Run the database seeds. * * @return void */ public function run()
{
$this->call(RoleTableSeeder::class);
$this->call(UserTableSeeder::class);
}
}
my UserTableSeeder file is `
use Illuminate\Database\Seeder;
use App\User;
use App\Role;
class UserTableSeeder extends Seeder
{
/** * Run the database seeds. * * @return void */ public function run()
{
$role_user = Role::where('name', 'User')->first();
$role_author = Role::where('name', 'Author')->first();
$role_admin = Role::where('name', 'Admin')->first();
$user = new User();
$user->first_name = 'Victor';
$user->last_name = 'Visitor';
$user->email = 'visitor@example.com';
$user->password = bcrypt('visitor');
$user->save();
$user->roles()->attach($role_user);
$admin = new User();
$admin->first_name = 'Alex';
$admin->last_name = 'Admin';
$admin->email = 'admin@example.com';
$admin->password = bcrypt('admin');
$admin->save();
$admin->roles()->attach($role_admin);
$author = new User();
$author->first_name = 'Andy';
$author->last_name = 'Author';
$author->email = 'author@example.com';
$author->password = bcrypt('author');
$author->save();
$author->roles()->attach($role_author);
}
} `
my RoleTableeSeeder file is `
use Illuminate\Database\Seeder; use App\Role;
class RoleTableSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { $role_user = new Role(); $role_user->name = 'User'; $role_user->description = 'A normal User'; $role_user->save();
$role_author = new Role();
$role_author->name = 'Author';
$role_author->description = 'An Author';
$role_author->save();
$role_admin = new Role();
$role_admin->name = 'Admin';
$role_admin->description = 'A Admin';
$role_admin->save();
}
} `
via anmol hans