Home > database >  Laravel Forge database seeder
Laravel Forge database seeder

Time:03-01

I'm trying to insert a user into my laravel forge site automatically, but the seeder is not working. I can create a user and log in, but I'm trying to have a default admin user once the site is live.

class UsersTableSeeder extends Seeder
{
    public function run()
    {
        DB::table('users')->insert([
            'name' => 'Jovani Calixte',
            'is_admin' => 1,
            'email' => '[email protected]',
            'password' => bcrypt('password'),
        ]);
    }
}

and this the database user php file

class DatabaseSeeder extends Seeder
{
    public function run()
    {
        
        $this->call(UsersTableSeeder::class);
    }
}

When I deploy the site to forge and try to log in I get the following error. What am I doing wrong?

  1. Whoops! Something went wrong.
  2. These credentials do not match our records.

CodePudding user response:

If you want to seed the database on the Forge provisioned server, you can log into Forge and navigate to your server/site, and click "Commands" in the navbar on the left, you can then run the command for your seeder,

php artisan db:seed

or

php artisan db:seed --class=UsersTableSeeder

To ensure that this data did indeed seed, you should check your users table to make sure that the record is in the table.

  • Related