Laravel includes the ability to seed your database with test data using seed classes. All seed classes are stored in the database/seeders directory. By default, a DatabaseSeeder class is defined for you. From this class, you may use the call method to run other seed classes, allowing you to control the seeding order.
To generate a seeder, execute the make:seeder Artisan command. All seeders generated by the framework will be placed in the database/seeders directory:
A seeder class only contains one method by default: run . This method is called when the db:seed Artisan command is executed. Within the run method, you may insert data into your database however you wish. You may use the query builder to manually insert data or you may use Eloquent model factories.
As an example, let’s modify the default DatabaseSeeder class and add a database insert statement to the run method:
You may type-hint any dependencies you need within the run method’s signature. They will automatically be resolved via the Laravel service container.
Using Model Factories
Of course, manually specifying the attributes for each model seed is cumbersome. Instead, you can use model factories to conveniently generate large amounts of database records. First, review the model factory documentation to learn how to define your factories.
For example, let’s create 50 users that each has one related post:
Calling Additional Seeders
Within the DatabaseSeeder class, you may use the call method to execute additional seed classes. Using the call method allows you to break up your database seeding into multiple files so that no single seeder class becomes too large. The call method accepts an array of seeder classes that should be executed:
You may execute the db:seed Artisan command to seed your database. By default, the db:seed command runs the Database\Seeders\DatabaseSeeder class, which may in turn invoke other seed classes. However, you may use the –class option to specify a specific seeder class to run individually:
You may also seed your database using the migrate:fresh command in combination with the –seed option, which will drop all tables and re-run all of your migrations. This command is useful for completely re-building your database:
Forcing Seeders To Run In Production
Some seeding operations may cause you to alter or lose data. In order to protect you from running seeding commands against your production database, you will be prompted for confirmation before the seeders are executed in the production environment. To force the seeders to run without a prompt, use the –force flag:
Database: Seeding Introduction Laravel includes the ability to seed your database with test data using seed classes. All seed classes are stored in the database/seeders directory. By default,
Seed Magic: How to germinate seeds in one day (with printable)
Inside: germinate seeds in one day and more spring seed inspiration for kids. Free printable.
Do you want to demonstrate to your kids how seeds turn into plants but worry that they don’t have the required attention span to follow the project to the end? We have the solution! With our marvelous technique, the seeds germinate in one day. And you have tiny plants in as little as 2-3 days (depending on the type of plant).
I find that kids are naturally curious about seeds, plants, and how things grow. The right books make them even more excited about the topic. We have many favorite seed books, but every spring we are especially inspired by Seed Magic. In this story, a young girl’s life is changed when she is given seeds to grow a garden under her window.
What you need
A plate that can fit inside a gallon bag
A gallon bag/Cling Wrap
A small toy or bottle cap to lift the wrap/bag off the seeds
Note: If you prefer to avoid plastic, you can use a glass container with a lid instead, but it will take longer because kids will want to peek inside. Even relatively clear lids like ours don’t allow a clear view, and kids end up opening them multiple times a day to get a better look, slowing down the germination. For quick results use a plate and a gallon bag method because it allows kids to observe the seeds all day long without disturbing the seeds.
Related: Looking for more science ideas? Check out Kid Minds Science Page.
Germinate Seeds in One Day
What to do
- Soak a paper towel under running water and squeeze most the water out of the towel. (So it will be wet, but not dripping).
- Spread the towel on the plate folded in half.
- Place seeds on the towel.
- If you are planting different seeds, write down on the gallon bag/Cling Wrap where each is located.
- Slide the plate into the bag.
- Place a little something (we used our popsicle mold cover) in the middle of the plate to lift the plastic off the seeds by half an inch.
- Voila! Get out your clocks and start counting down the hours. I find that seeds and planting are a great way to teach kids about time.
Note: All seeds are not created equal. From our experiments, we found that radish germinates in less than 24 hours and can be planted on a second/third day. Russian Kale and beets are close behind. Tomatoes take a few days and tomatillos even longer. If you want to plant flowers, you will get quick results with Cypress Pennata Red. It’s a beautiful red climbing flower that I plant every summer at the bottom of our fence (and within a month I’m looking at a sea of waving greens and reds). Some other flowers we had success with are cornflowers and marigolds.
Use our Seed Observation Journal to record your observations. You can access all of our Printables in the Subscribers-only Library of Resources. To subscribe click here.
Next morning (in less than 24 hours)
Here is a pic of radish. Can you believe it!
And here is Russian Kale
It’s getting there.
I peeked at our seeds in the morning and realized that if we didn’t plant them right away, they would grow into the paper towel. Once the seeds grow into the paper towel you have to plant them together. Pulling the plant out of the paper towel, however gently, usually damages it beyond recovery.
Are you wondering why we didn’t plant our tiny germinated seeds into bigger pots? We actually did plant half of our seeds into bigger pots, and they are still so tiny we can barely see them. I think there might be two reasons for this result. First, it’s easier for kids to take care of egg cartons. The kids put a drop of water in each section every day. On the other hand, big pots were always either completely drenched or dry as toast. And second, we only have space for one or the other in front of our sunny kitchen windows. Since the place was occupied by the plants in egg cartons, the big pots had to be in the shade. My guess is that they didn’t like it!
Our plants are 9 inches tall!
The kind of soil that goes into planting radishes is very important. We have tried a variety of soil mixes, and we can definitely taste the difference!
I will update you on Instagram when we eat our first radish of the year.
Disclaimer: This post contains an Amazon affiliate link.
This method is also great if you are serious about gardening. No more waiting for weeks to see if something will grow. With this approach, you know if seeds are viable in the shortest amount of time.
Looking for more science ideas?
This month we were invited to participate in the Storybook Science Series hosted by Inspirational Laboratories. If you want to see more amazing science inspiration from wonderful bloggers, click here.
Germinate seeds in one day and more spring seed inspiration. Free Printable and lots of photos. Great for elementary grades and older kids too.