-
Notifications
You must be signed in to change notification settings - Fork 26
Seeding
Yo-An Lin edited this page May 14, 2017
·
2 revisions
Seed Script is used to create a set of base data that helps you to setup the application. for example, you might need to create the city records for the city name selector, then you can define a CitySeed that creates the City names into the database.
To define a basedata seed script:
<?php
namespace AuthorBooks;
use Maghead\Runtime\BaseSeed;
class MySeed extends BaseSeed {
public static function seed() {
Model\Author::create([ 'name' => 'John' ]);
Model\Book::create([ 'name' => 'Programming PHP' ]);
}
}Then update your config file by adding the class name of the data seed class:
seeds:
- AuthorBook::MySeedTo execute the seed scripts, run the command below:
php bin/maghead seed