In this tutorial, we will show how to seed an admin user without exposing private information.

To do so, we will store a user's name, email, and password in the .env file, for spinning up a new admin user, quickly. Additionally, this method allows for setting credentials based on development environments.

.env file

Add the following variables to your .env file:


Do not forget to add the above variables, without values, to the .env.example file for reference, and also, you should add a corresponding notes in the readme file.

Next, create a new file under /config/ directory, and call it admin.php.

return [
    'admin_name' => env('ADMIN_NAME', ''),
    'admin_email' => env('ADMIN_EMAIL', ''),
    'admin_password' =>env('ADMIN_PASSWORD', '')

Next, create a database seeder:

php artisan make:seeder NovaUserSeeder

Modify the seeder


use App\User;
use Illuminate\Database\Seeder;

class NovaUserSeeder extends Seeder
    public function run()
        if (config('admin.admin_name')) {
                ['email' => config('admin.admin_email')],
                    'name' => config('admin.admin_name'),
                    'password' => bcrypt(config('admin.admin_password')),


Add the following code to run() method to your database/seeds/DatabaseSeeder.php:


Refresh and seed the database

composer dump-autoload
php artisan migrate:refresh --seed

// or

php artisan db:seed --force