You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: seeding.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,14 @@
9
9
<aname="introduction"></a>
10
10
## Introduction
11
11
12
-
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.
12
+
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 `UserSeeder`, 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.
13
13
14
14
<aname="writing-seeders"></a>
15
15
## Writing Seeders
16
16
17
17
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:
18
18
19
-
php artisan make:seeder UsersTableSeeder
19
+
php artisan make:seeder UserSeeder
20
20
21
21
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}}/database-testing#writing-factories).
22
22
@@ -82,9 +82,9 @@ Within the `DatabaseSeeder` class, you may use the `call` method to execute addi
82
82
public function run()
83
83
{
84
84
$this->call([
85
-
UsersTableSeeder::class,
86
-
PostsTableSeeder::class,
87
-
CommentsTableSeeder::class,
85
+
UserSeeder::class,
86
+
PostSeeder::class,
87
+
CommentSeeder::class,
88
88
]);
89
89
}
90
90
@@ -99,7 +99,7 @@ Now you may use the `db:seed` Artisan command to seed your database. By default,
99
99
100
100
php artisan db:seed
101
101
102
-
php artisan db:seed --class=UsersTableSeeder
102
+
php artisan db:seed --class=UserSeeder
103
103
104
104
You may also seed your database using the `migrate:fresh` command, which will drop all tables and re-run all of your migrations. This command is useful for completely re-building your database:
0 commit comments