Laravel Data Seeding

Creating a simple seeder

You’ll find your seeder files under database > seeders

Create a new one with this:

php artisan make:seeder UsersTableSeeder

Open new file and add to run function:

            'name' => Str::random(10),
            'email' => Str::random(10).'',
            'password' => bcrypt('secret')

At the top of document add:

use DB;
use Str;

Now run:

php artisan db:seed

Creating a more advanced seeder with factories

Leave a Reply

Your email address will not be published.