Seeders
Introduction
This is a Guide to use Seeders
in VaahCMS.
Basically Seeder
is a class used to seed the database with data. In VaahCMS All the
seed
classes are stored in the Database\Seeds
directory.
Follow below image for reference:
Types of Seeders in VaahCMS
There are two types of Seeders
in VaahCMS:
- DatabaseTableSeeder
- SampleDataTableSeeder
Follow below image for references:
We will get to know about both these Seeders
one by one.
1. DatabaseTableSeeder :
This Seeder is used to seed the database with necessary data.
All the necessary functions, which are required for the module and theme are placed inside run
method of DatabaseTableSeeder.
Follow below image for reference:
The run
method of DatabaseTableSeeder
is called whenever any module or theme is activated by the user
and it seeds the database with the data.
2. SampleDataTableSeeder :
SampleDataTableSeeder is used to seed test
data into the database
for the module or the theme. Whenever we want to insert
test data into the database
we can use run
method of this Seeder
class to seed the test data.
To use SampleDataTableSeeder
we need to click on import sample data
for the particular module or the theme.
Follow below image for reference:
Once we click on this Import Sample Data
button run
method of SampleDataTableSeeder
is called
and data is seeded into the database.