Skip to content

Commit

Permalink
seeding docs
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 2, 2016
1 parent acb4d4c commit d8f1a2c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions seeding.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@
<a name="introduction"></a>
## Introduction

Laravel includes a simple method of seeding your database with test data using seed classes. All seed classes are stored in `database/seeds`. Seed classes may have any name you wish, but probably should follow some sensible convention, such as `UsersTableSeeder`, etc. 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.
Laravel includes a simple method of seeding your database with test data using seed classes. All seed classes are stored in the `database/seeds` directory. Seed classes may have any name you wish, but probably should follow some sensible convention, such as `UsersTableSeeder`, etc. 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.

<a name="writing-seeders"></a>
## Writing Seeders

To generate a seeder, you may issue the `make:seeder` [Artisan command](/docs/{{version}}/artisan). All seeders generated by the framework will be placed in the `database/seeds` directory:
To generate a seeder, execute the `make:seeder` [Artisan command](/docs/{{version}}/artisan). All seeders generated by the framework will be placed in the `database/seeds` directory:

php artisan make:seeder UsersTableSeeder

A seeder class only contains one method by default: `run`. This method is called when the `db:seed` [Artisan command](/docs/{{version}}/artisan) is executed. Within the `run` method, you may insert data into your database however you wish. You may use the [query builder](/docs/{{version}}/queries) to manually insert data or you may use [Eloquent model factories](/docs/{{version}}/testing#model-factories).

As an example, let's modify the `DatabaseSeeder` class which is included with a default installation of Laravel. Let's add a database insert statement to the `run` method:
As an example, let's modify the default `DatabaseSeeder` class and add a database insert statement to the `run` method:

<?php

Expand Down

0 comments on commit d8f1a2c

Please sign in to comment.