'Create database with initial data in Laravel running project

I have a running project from another server. I installed it locally on my machine with an admin username and password. However, I ran a command that deleted all my database information, so it's returned to fresh databases. Is there any method to get the initial databases?

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        // Create Roles
        $roles = ['admin', 'instructor', 'student', 'parent', 'guest', 
            'employee', 'institute', 'candidate'];

        foreach ($roles as $role) {
            Role::create(['name' => $role]);
        }
    }

    // Create user and assign admin role 
    $user = User::create([
        'first_name' => 'QwikTest',
        'last_name' => 'Admin',
        'user_name' => 'admin',
        'email' => '[email protected]',
        'password' => Hash::make('password'),
        'email_verified_at' => Carbon::now()->toDateTimeString()
    ]);

    $user->assignRole('admin');
}


Solution 1:[1]

The command for seeding is this:

php artisan db:seed

or, with fresh migration:

php artisan migrate:fresh --seed

Solution 2:[2]

Personally, I'd grab a full database backup from production either through workbench or phpmyadmin. Then just add that backup to your local database. No migrations to run and good data to play with. Your admin password locally will be the same as production.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Laisender
Solution 2