Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create post factory with relationships fields
//create 15 posts with 3 comments and 3 tags each
$posts = factory('App\Post', 15)
->create()
->each(function($post) {
foreach(range(1,3) as $v){
$post->comments()->save(factory('App\Comment')->make());
$post->tags()->save(factory('App\Tag')->make());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.