Skip to content

Instantly share code, notes, and snippets.

@naneri
Created February 23, 2016 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naneri/b253c0247f23f383a661 to your computer and use it in GitHub Desktop.
Save naneri/b253c0247f23f383a661 to your computer and use it in GitHub Desktop.
Laravel tricks

Adding seed data to migrations.

It often happens that you need some data to be available inside a migration. But the same data might be required in a Seeder (if you want to run it on test environtment). To make the data available for both in Seeder and Migration - you can simply call it inside a migration. Like that:

$seeder = new YourClassSeeder();
$seeder->run();

But you have to check inside the seeder file if the data is already available for your App, (so that you would not end up with two sets of the same data, after calling both migrations and seeders in testing machine).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment