Skip to content

Instantly share code, notes, and snippets.

@subdesign
Created February 16, 2014 13:35
Show Gist options
  • Save subdesign/9034300 to your computer and use it in GitHub Desktop.
Save subdesign/9034300 to your computer and use it in GitHub Desktop.
Faker 2
<?php
class ArticlesTableSeeder extends Seeder {
public function run()
{
// létrehoz egy Faker objektumot
$faker = Faker\Factory::create();
// 5 cikket hoz létre
foreach( range(1, 5) as $item )
{
Article::create(array(
// generál egy három szóból álló címet
'title' => $faker->sentence(3),
// generál egy 4 mondatból álló tartalmat
'content' => $faker->paragraph(4),
// a cikkek dátuma a mostani dátum és két héttel korábbani dátum között lesz véletlenszerűen
'created_at' => $faker->dateTimeBetween('now', '+14 days')
));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment