Skip to content
Advertisement

How to set the username and password for the admin using database table?

I have created a website with login form for the administrator. I have the admin table in my database. I added the values in the table but when I try to login, the password is not being accepted. My table is as below

enter image description here

How can I set username and password for admins using database table?

Advertisement

Answer

You should create a hash for the password and I will suggest to use tinker. Just goto your project directory via cmd and type this command

php artisan tinker

Then Enter below lines to create admin. I assume you have admin model for the admins table!

$admin = new AppAdmin;
$admin->name= "admin";
$admin->email="admin@admin.com";
$admin->password= Hash::make('password');
$admin->save();
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement