Video Course

Build a Monthly Subscription App with Laravel Cashier: Lesson 4 of 36

Seeding

Up Next

Routing

Autoplaying in 7 seconds!

Cancel

Create a Free Account to Watch

Sign Up Now

Login to your account

We have the database tables and fields ready thanks to migrations. We also have the means to create fake data thanks to model factories.

The only thing left to do is to create our fake data. Here are the quick commands to get data into the database:

// database/seeds/DatabaseSeeder.php

// clear the database
DB::table('users')->delete();
DB::table('posts')->delete();

// fill the database
// the post model factory will create a new user/author for each post
factory(App\Post::class, 8)->create();

Then we can run the seeder with php artisan db:seed.

You'll be able to see the new posts and users in your database!

Chris Sevilleja

156 posts

Co-founder of Scotch.io. Slapping the keyboard until something good happens.